Edit report at https://bugs.php.net/bug.php?id=60202&edit=1
ID: 60202 Updated by: johan...@php.net Reported by: cmanley at office dot caiw dot nl Summary: Please add __STATIC__ magic constant Status: Bogus Type: Feature/Change Request Package: *General Issues PHP Version: 5.3.8 Block user comment: N Private report: N New Comment: Sorry, misread your request. But a constant can't be done for technical reasons. The value of the magic constant has to be known at compile time, but the lsb name is only known at run time. Previous Comments: ------------------------------------------------------------------------ [2011-11-02 17:05:43] johan...@php.net You can use the static keyword for that. See http://php.net/lsb ------------------------------------------------------------------------ [2011-11-02 14:20:58] cmanley at office dot caiw dot nl Description: ------------ Please add a __STATIC__ magic constant so that a static method can know the name of the class that it was called on. In other words: class A { static function bla() { print __STATIC__; } } class B extends A {} print B::bla() . "\n"; // I want this to print "B". See also: http://www.php.net/manual/en/language.constants.predefined.php#84050 Test script: --------------- // This is how it is currently done: php -r 'class A { static function bla() { print get_called_class(); }} class B extends A {} print B::bla() . "\n";' B // This would be more consistent and convenient: php -r 'class A { static function bla() { print __STATIC__; }} class B extends A {} print B::bla() . "\n";' B ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=60202&edit=1