Re: PHP5 - instanceof
| From: | Greg Beaver | Date: | Thu, 13 May 2004 13:53:18 +0000 |
| Subject: | Re: PHP5 - instanceof | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-186101@lists.php.net to get a copy of this message | ||
Martin Towell wrote:
I have been playing with PHP5 and am liking it more and more. But I have one question about "instanceof" If you have something like this: <? class A { } class B extends A { } $x = new B; if ($x instanceof B) echo "B"; if ($x instanceof A) echo "A"; ?> This would echo "BA". That's good, I understand that. Now the question: Is it possible to determine if B is an instance of A without instantiating it? Thanks MartinHi Martin, Reflection is your friend. <?php class A { } class B extends A { } $x = new Reflection_Class('B'); print_r($x); ?> Greg -- phpDocumentor http://www.phpdoc.org