note 58812 deleted from function.get-class by cmb
| From: | cmb@php.net | Date: | Wed, 30 Nov 2016 16:31:14 +0000 |
| Subject: | note 58812 deleted from function.get-class by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-207754@lists.php.net to get a copy of this message | ||
Note Submitter: brjann at NOSPAMATALLgmail dot com
----
This behavior is unexpected, but good to be aware of
class parentclass {
public function getClass(){
echo get_class($this); //using "$this"
}
}
class child extends parentclass {
}
$obj = new child();
$obj->getClass(); //outputs "child"
class parentclass {
public function getClass(){
echo get_class(); //note, no "$this"
}
}
class child extends parentclass {
}
$obj = new child();
$obj->getClass(); //outputs "parentclass"