note 71574 added to function.get-class
| From: | lukeatliveoakinteractivedotcom at osu1 dot php dot net | Date: | Wed, 06 Dec 2006 15:03:28 +0000 |
| Subject: | note 71574 added to function.get-class | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-120339@lists.php.net to get a copy of this message | ||
This note is a response to the earlier post by davidc at php dot net. Unfortunately, the solution
posted for getting the class name from a static method does not work with inherited classes.
Observe the following:
<?php
class BooBoof {
public static function getclass() {
return __CLASS__;
}
public function retrieve_class() {
return get_class($this);
}
}
class CooCoof extends BooBoof {
}
echo CooCoof::getclass();
// outputs BooBoof
$coocoof = new CooCoof;
echo $coocoof->retrieve_class();
// outputs CooCoof
?>
__CLASS__ and get_class($this) do not work the same way with inherited classes. I have been thus far
unable to determine a reliable way to get the actual class from a static method.
----
Server IP: 64.71.164.2
Probable Submitter: 24.155.147.132
----
Manual Page -- http://www.php.net/manual/en/function.get-class.php
Edit -- https://master.php.net/note/edit/71574
Del: integrated -- https://master.php.net/note/delete/71574/integrated
Del: useless -- https://master.php.net/note/delete/71574/useless
Del: bad code -- https://master.php.net/note/delete/71574/bad+code
Del: spam -- https://master.php.net/note/delete/71574/spam
Del: non-english -- https://master.php.net/note/delete/71574/non-english
Del: in docs -- https://master.php.net/note/delete/71574/in+docs
Del: other reasons-- https://master.php.net/note/delete/71574
Reject -- https://master.php.net/note/reject/71574
Search -- https://master.php.net/manage/user-notes.php