|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2011-11-02 17:05 UTC] johannes@php.net
[2011-11-02 17:05 UTC] johannes@php.net
-Status: Open
+Status: Bogus
[2011-11-02 17:07 UTC] johannes@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 19 11:00:01 2025 UTC |
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