lbjay can be emailed at reallywow dot com
03-May-2003 03:18
I'm not even sure how to articulate this, so I'm going to just include test
code. Maybe someone else will someday wonder the same
thing.
<?
error_reporting(E_ALL);
class
testParent
{
var $child;
function
testParent()
{
$this->child = new
testChild();
}
}
class testChild
{
function testChild()
{
}
}
$parent = new testParent();
$parent2 = 'foobar';
print
join(',', Array(
is_object($parent) ? 'yes' : 'no',
is_object($parent->child) ? 'yes' : 'no',
is_object($parent2)
? 'yes' : 'no',
is_object($parent2->child) ? 'yes' : 'no'
));
?>
This prints "yes,yes,no,no". Basically
this shows that you can use is_object to test if the child object is an
object without worrying about an error if the parent object isn't an object
either.