Re: [PHP] Re: is_a() against instanceof

2005-03-20 Thread Marek Kilimajer
Jason Barnett wrote: Christian Stadler wrote: Eli schrieb: - ($cls instanceof ClassName) *requires* from ClassName to be declared, and generates a fatal error when ClassName is not declared. How about if (class_exists('ClassName') AND $cls instanceof ClassName) { ... } Regards, Christian Stadl

[PHP] Re: is_a() against instanceof

2005-03-20 Thread Christian Stadler
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Jason Barnett schrieb: > Nice suggestion! But I wonder... would it perhaps be better to use the > && operator instead of the AND operator? That way in case you are > trying to do an assignment PHP won't bother to check instanceof if the > class_exist

[PHP] Re: is_a() against instanceof

2005-03-16 Thread Jason Barnett
Christian Stadler wrote: > Eli schrieb: > >>>- ($cls instanceof ClassName) *requires* from ClassName to be declared, >>>and generates a fatal error when ClassName is not declared. > > How about > if (class_exists('ClassName') AND $cls instanceof ClassName) > { >... > } > > Regards, > Christi

[PHP] Re: is_a() against instanceof

2005-03-15 Thread Christian Stadler
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Eli schrieb: > - ($cls instanceof ClassName) *requires* from ClassName to be declared, > and generates a fatal error when ClassName is not declared. How about if (class_exists('ClassName') AND $cls instanceof ClassName) { ... } Regards, Christia

[PHP] Re: is_a() against instanceof

2005-03-15 Thread Eli
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

[PHP] Re: is_a() against instanceof

2005-03-15 Thread Jason Barnett
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 -- Teach a man to fish... NEW? | http://www.catb.org/~esr/faqs/smart-quest