note 115145 deleted from classobj.examples by cmb
| From: | cmb@php.net | Date: | Wed, 02 Sep 2015 21:50:12 +0000 |
| Subject: | note 115145 deleted from classobj.examples by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-203587@lists.php.net to get a copy of this message | ||
Note Submitter: simon at caperet dot com
----
The code above doesn't work - throws Warning
Warning: get_class() called without object from outside a class in (filename)
The line
<?php
echo "Object $obj belongs to class " . get_class($$obj);
?>
should read
<?php
echo "Object $obj belongs to class " . get_class($GLOBALS[$obj]);
?>
And, for those who are interested, full output is :
veggie: CLASS Vegetable
leafy: CLASS Spinach, PARENT Vegetable
veggie: Properties
edible = 1
color = blue
leafy: Methods
function Spinach()
function cook_it()
function is_cooked()
function Vegetable()
function is_edible()
function what_color()
Parentage:
Object leafy does not belong to a subclass of Spinach
Object leafy belongs to class Spinach a subclass of Vegetable