note 73461 added to language.operators.type
| From: | Wombert at osu1 dot php dot net | Date: | Fri, 23 Feb 2007 22:54:12 +0000 |
| Subject: | note 73461 added to language.operators.type | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-123793@lists.php.net to get a copy of this message | ||
mikael dot knutsson at gmail dot com is wrong, the correct way to check if an object is NOT an
instance of a class is:
<?php
if(!($foo instanceof Bar)) {
// CORRECT
}
?>
If you do
<?php
if(!$foo instanceof Bar) {
// WRONG, WRONG, WRONG
}
?>
then the result of the expression is the instanceof comparison done on the negation of the object.
That's not what you want.
----
Server IP: 212.124.37.9
Probable Submitter: 84.56.3.195
----
Manual Page -- http://www.php.net/manual/en/language.operators.type.php
Edit -- https://master.php.net/note/edit/73461
Del: integrated -- https://master.php.net/note/delete/73461/integrated
Del: useless -- https://master.php.net/note/delete/73461/useless
Del: bad code -- https://master.php.net/note/delete/73461/bad+code
Del: spam -- https://master.php.net/note/delete/73461/spam
Del: non-english -- https://master.php.net/note/delete/73461/non-english
Del: in docs -- https://master.php.net/note/delete/73461/in+docs
Del: other reasons-- https://master.php.net/note/delete/73461
Reject -- https://master.php.net/note/reject/73461
Search -- https://master.php.net/manage/user-notes.php