note 62819 added to language.operators.type
| From: | MikeH at osu1 dot php dot net | Date: | Fri, 10 Mar 2006 11:14:33 +0000 |
| Subject: | note 62819 added to language.operators.type | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-105185@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 85.116.0.130
Probable Submitter: 80.177.252.222
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/language.operators.type.php
Edit -- http://master.php.net/note/edit/62819
Del: integrated -- http://master.php.net/note/delete/62819/integrated
Del: useless -- http://master.php.net/note/delete/62819/useless
Del: bad code -- http://master.php.net/note/delete/62819/bad+code
Del: spam -- http://master.php.net/note/delete/62819/spam
Del: non-english -- http://master.php.net/note/delete/62819/non-english
Del: in docs -- http://master.php.net/note/delete/62819/in+docs
Del: other reasons-- http://master.php.net/note/delete/62819
Reject -- http://master.php.net/note/reject/62819
Search -- http://master.php.net/manage/user-notes.php