note 121771 deleted from classobj.examples by salathe
| From: | salathe@php.net | Date: | Mon, 21 Sep 2020 14:31:04 +0000 |
| Subject: | note 121771 deleted from classobj.examples by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-215182@lists.php.net to get a copy of this message | ||
Note Submitter: denisn1 at free dot fr
----
In order to avoid an "Undefined variable" error, the class_parentage fucntion should have
the global $$obj stattement :
function class_parentage($obj, $class) {
global $$obj;
if (is_subclass_of($GLOBALS[$obj], $class)) {
echo "L'objet $obj appartient à la classe " . get_class($$obj);
echo " une sous-classe de $class\n";
} else {
echo "L'object $obj n'appartient pas à une sous-classe $class\n";
}
}