#31716 [Opn->Bgs]: get_class() with no argument, always return the original classname

From: Date: Fri, 28 Jan 2005 22:26:53 +0000
Subject: #31716 [Opn->Bgs]: get_class() with no argument, always return the original classname
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-73011@lists.php.net to get a copy of this message
ID: 31716 Updated by: tony2001@php.net Reported By: wildmaple at yahoo dot com -Status: Open +Status: Bogus Bug Type: Class/Object related Operating System: linux PHP Version: 5.0.3 New Comment: See #31686, describing the very same problem. Previous Comments: ------------------------------------------------------------------------ [2005-01-27 08:27:01] wildmaple at yahoo dot com And I can't get the inherited class name by self, self always point to parent class too. ------------------------------------------------------------------------ [2005-01-27 08:12:28] wildmaple at yahoo dot com Description: ------------ get_class() invoked with no argument, always return the original classname, in which it is first referenced. Reproduce code: --------------- #!/bin/php <?php class parentCls{ static function initPStatic(){ echo("parentCls::initPStatic said get_class()=='".get_class()."'\n"); echo("\n"); } function initP(){ echo("parentCls::initP said get_class()=='".get_class()."'\n"); echo("\n"); } } class childCls extends parentCls{ } childCls::initPStatic(); $c=new childCls(); $c->initP(); ?> Expected result: ---------------- parentCls::initPStatic said get_class()=='childCls' parentCls::initP said get_class()=='childCls' Actual result: -------------- parentCls::initPStatic said get_class()=='parentCls' parentCls::initP said get_class()=='parentCls' ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=31716&edit=1

« previous php.bugs (#73011) next »