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 { function 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, 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, Andrey
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php