Re: PHP5 extensions: using existing functionnames as method names

php.internals

Unnamed Person

19 years ago
...Just forgot to CC...
>you can use any function name as method name without a clash. you just >cannot use language constructs that aren't real functions like >"empty", "echo" or "require" as method names.
>this question better belongs to php-general, btw.
Sorry if I didn't made myself clear enough. I'm talking about C-extensions. I've tried to implement the PHP_METHOD(class, xyz). It compiles fine, but in runtime "PHP Warning: cannot redeclare xyz..." will appaer. Daniel

Pierre Joye

19 years ago
On Wed, 13 Sep 2006 11:35:16 +0200 danhen@email.de wrote:
> ...Just forgot to CC... > >you can use any function name as method name without a clash. you > >just cannot use language constructs that aren't real functions like > >"empty", "echo" or "require" as method names. > > >this question better belongs to php-general, btw. > > Sorry if I didn't made myself clear enough. I'm talking about > C-extensions. I've tried to implement the PHP_METHOD(class, xyz). It > compiles fine, but in runtime "PHP Warning: cannot redeclare xyz..." > will appaer.
It is possible to name a method like an existing function, I'm not sure what you are doing exactly but it works here. When your class is called zip and you have a function called zip_open, it will conflict with the function name when you build against php < 5.2.0. It is fixed in 5.2 and a work around exists, see ext/zip for an example. -- Pierre