php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #31716 get_class() with no argument, always return the original classname
Submitted: 2005-01-27 08:12 UTC Modified: 2005-01-28 23:26 UTC
From: wildmaple at yahoo dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.0.3 OS: linux
Private report: No CVE-ID: None
 [2005-01-27 08:12 UTC] 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'

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-01-27 08:27 UTC] 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-28 23:26 UTC] tony2001@php.net
See #31686, describing the very same problem.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 09:01:29 2024 UTC