#41072 [Opn]: Make instanceof work without the need of creating the object first
| From: | stas@php.net | Date: | Sun, 29 Apr 2007 12:07:15 +0000 |
| Subject: | #41072 [Opn]: Make instanceof work without the need of creating the object first | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-112034@lists.php.net to get a copy of this message | ||
ID: 41072
Updated by: stas@php.net
Reported By: atomo64 at gmail dot com
Status: Open
Bug Type: Feature/Change Request
Operating System: Linux 2.6.18 SMP i686
PHP Version: 5.2.1
New Comment:
I'd suggest you use reflection for this:
http://www.php.net/reflection
Previous Comments:
------------------------------------------------------------------------
[2007-04-13 00:49:11] atomo64 at gmail dot com
Description:
------------
At the moment instanceof requires the first 'parameter' to be an object
of the class which is to be compared.
It would be useful to be able to check without creating the object.
Reproduce code:
---------------
<?php
class MyClass {}
$class = 'MyClass';
var_dump($class instanceof MyClass);
var_dump($$class instanceof MyClass);
var_dump(MyClass instanceof MyClass);
?>
Expected result:
----------------
bool(false)
bool(true)
bool(true)
Actual result:
--------------
bool(false)
bool(false)
bool(false)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41072&edit=1