|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-12-04 12:27 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 03:00:01 2025 UTC |
Description: ------------ In an inherited function, get_class() gives the name of the parent class get_class($this) gives the name of the child class. These should be consistent and return the name of the child class. Before you get deja vu and mark this bogus, I think that 31716 and 31616 were closed improperly as they deal with inheitance, NOT static isuses like 30964/30140. Reproduce code: --------------- <?php class Parentclass { function inherited_func() { echo "In inherited_func():\n__CLASS__ = " . __CLASS__ . "\nget_class() = " . get_class() . "\nget_class(\$this) = " . get_class($this) . "\n"; } } class Childclass extends Parentclass { function func() { echo "In func():\n__CLASS__ = " . __CLASS__ . "\nget_class() = " . get_class() . "\nget_class(\$this) = " . get_class($this) . "\n"; } } $c = new Childclass(); echo "<pre> phpversion()=" . phpversion() . "\n"; $c->func(); $c->inherited_func(); ?> Expected result: ---------------- I expect get_class() and get_class($this) to return "Childclass". Actual result: -------------- phpversion()=5.1.2-dev In func(): __CLASS__ = Childclass get_class() = Childclass get_class($this) = Childclass In inherited_func(): __CLASS__ = Parentclass get_class() = Parentclass get_class($this) = Childclass