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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: wildmaple at yahoo dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 15:01:34 2025 UTC