Re: wrong behaviour with is_subclass_of() ??

From: Date: Fri, 19 Sep 2008 16:24:42 +0000
Subject: Re: wrong behaviour with is_subclass_of() ??
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-280524@lists.php.net to get a copy of this message
Jochem Maas wrote:
B implements I
because B subclasses A and A implements I, I is not a base class. try the experiment with is_a() instead.
This was my starting point and is_subclass_of() was a sub-ordinate target, because i needed it on the class-side of life and not the instantiated way.
also you should preferablly use the instanceof syntax: <?php $a = new A; $b = new B; if ($a instanceof I)) echo "A implements I\n"; if ($b instanceof I)) echo "B implements I\n"; or use the return data from class_implements(), is_subclass_of()
class_implements() would solve all these problems were well!
specifically looks at base classes ("extends"), I'm a little surprised that it even returns true for interfaces at all ("implements").
And this was the reason where it stops to make sense for me. And if you hadn't pointed this out, this would have been in my next email. Johannes

« previous php.general (#280524) next »