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
Martin

Hi 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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to