Re: is_a() against instanceof

From: Date: Wed, 16 Mar 2005 00:44:40 +0000
Subject: Re: is_a() against instanceof
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-210866@lists.php.net to get a copy of this message
Jason Barnett wrote:
Eli wrote: ...
- is_a($cls,"ClassName") *doesn't require* from ClassName to be declared, and return false when ClassName is not declared.
... Try is_subclass_of() http://php.net/manual/en/function.is-subclass-of.php is_subclass_of() is not exactly like is_a(), in that it will return false if the object is exactly from the class.
$cls=new ClassName(); var_dump(is_subclass_of($cls,"ClassName")); //dumps: FALSE! var_dump(is_a($cls,"ClassName")); //dumps: TRUE!

« previous php.general (#210866) next »