note 62819 deleted from language.operators.type by colder

From: Date: Sat, 24 Feb 2007 10:03:17 +0000
Subject: note 62819 deleted from language.operators.type by colder
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-123813@lists.php.net to get a copy of this message
Note Submitter: MikeH ---- This will fail: <? if ($moo instanceof "Moo") echo "Goo\n"; ?> and this will not: <? if ($moo instanceof Moo) echo "Goo\n"; ?> and although you cant use a quoted string as the class name to check, you can use a variable like this: <? $moo_class = "Moo"; if ($moo instanceof $moo_class) echo "Goo\n"; ?> so if you want to loop through an array of class names to check an object against, you can do it easily.

« previous php.notes (#123813) next »