Re: PHP5: expected __METHOD__ behavior
| From: | Andrey Hristov | Date: | Sat, 22 May 2004 00:33:52 +0000 |
| Subject: | Re: PHP5: expected __METHOD__ behavior | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-10020@lists.php.net to get a copy of this message | ||
Daniel J Cain Jr. wrote:
I am by no means an expert with OOP, so if this is a blatantly retarded question please excuse my ignorance. Given this code: <?php class A {this "constant" like the others is resolved on compile time. Another example is __CLASS__: php -r 'class a{ function c() {var_dump(__CLASS__);}}class b extends a{};$a=new b();$a->c();' dumps : string(1) "a" __METHOD__ is resolved as __CLASS__.'::'.__FUNCTION__ IMO the current behaviour is the normal since works like the C preprocessor doing substitutions before compile (PHP does it while compiling). You can get what you wanted with this : echo get_class($this).'::'.__FUNCTION__ (when there is an instance of the class) but AFAIK in your case with static calls there is no solution. Cheers, Andreyfunction foo() { echo __METHOD__; }} class B {function bar() { // blah }} $instance = B::foo(); ?> output is "A::foo". Is this correct? I would expect (want maybe :) ) to see output as "B::foo". If you need more information please let me know. TIA -dan Hi,