note 117491 added to internals2.opcodes.instanceof
| From: | portugal{at}jawira{dot}com | Date: | Wed, 17 Jun 2015 20:49:17 +0000 |
| Subject: | note 117491 added to internals2.opcodes.instanceof | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-202890@lists.php.net to get a copy of this message | ||
I'm commenting here because the note from "admin at torntech" is incomplete. You can
perfectly replace "is_a()" function with "instanceof" operator. However you must
use a variable to store the class name, otherwise you will get a Parse error:
<?php
$object = new \stdClass();
$class_name = '\stdClass';
var_dump($object instanceof $class_name); // bool(true)
var_dump($object instanceof '\stdClass'); // Parse error: syntax error, unexpected
''\stdClass'' (T_CONSTANT_ENCAPSED_STRING)
?>
Please go to Type Operators page for more details about "instanceof": http://php.net/manual/en/language.operators.type.php
----
Server IP: 72.52.91.14
Probable Submitter: 62.235.172.169
----
Manual Page -- http://php.net/manual/en/internals2.opcodes.instanceof.php
Edit -- https://master.php.net/note/edit/117491
Del: integrated -- https://master.php.net/note/delete/117491/integrated
Del: useless -- https://master.php.net/note/delete/117491/useless
Del: bad code -- https://master.php.net/note/delete/117491/bad+code
Del: spam -- https://master.php.net/note/delete/117491/spam
Del: non-english -- https://master.php.net/note/delete/117491/non-english
Del: in docs -- https://master.php.net/note/delete/117491/in+docs
Del: other reasons-- https://master.php.net/note/delete/117491
Reject -- https://master.php.net/note/reject/117491
Search -- https://master.php.net/manage/user-notes.php