#22960 [Opn->Bgs]: Value of the constant __CLASS__

From: Date: Mon, 31 Mar 2003 07:21:50 +0000
Subject: #22960 [Opn->Bgs]: Value of the constant __CLASS__
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-36761@lists.php.net to get a copy of this message
ID: 22960 Updated by: sniper@php.net Reported By: thixit at yahoo dot com -Status: Open +Status: Bogus Bug Type: Class/Object related PHP Version: 4.3.1 New Comment: It works as expected and intended. Previous Comments: ------------------------------------------------------------------------ [2003-03-30 05:54:27] thixit at yahoo dot com Concerning the magical constant __CLASS__ <?php class foo { function a() { print __CLASS__ . "\n"; } } class bar extends foo { function b() { print __CLASS__ . "\n"; } } $foo = new foo; $bar = new bar; print '<pre>'; $foo->a(); // foo $bar->a(); // foo $bar->b(); // bar print '</pre>'; ?> I'm not sure about the definition of magical constant, but IMHO __CLASS__ should be changed to reflect the current class that it is in at that moment. This would be useful when use it in a static method where get_class() cannot be used. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=22960&edit=1

« previous php.bugs (#36761) next »