Re: [PHP-DEV] is_a() versus instanceof

2009-12-19 Thread mm w
class rootObject { ... function isMemberOrInstanceOfClass($object) { $className = is_object($object) ? get_class($object) : $object; return ($this instanceof $className); } }; On Sat, Dec 19, 2009 at 2:20 AM, Johannes Mueller wrote: > Johannes "Schl

Re: [PHP-DEV] is_a() versus instanceof

2009-12-19 Thread Johannes Mueller
Johannes "Schlüter" wrote: On Sat, 2009-12-19 at 01:42 +0100, Johannes Mueller wrote: if($foo instanceof bar){ .. } // runs without any notification instanceof is a language construct expecting a class identifier. It doesn't complain about on-existing classes as it would need to trigger the __

Re: [PHP-DEV] is_a() versus instanceof

2009-12-18 Thread Jille Timmermans
Johannes Schlüter schreef: > On Sat, 2009-12-19 at 01:42 +0100, Johannes Mueller wrote: > >> if($foo instanceof bar){ >> .. >> } >> // runs without any notification >> > > instanceof is a language construct expecting a class identifier. > It doesn't complain about on-existing classes as it

Re: [PHP-DEV] is_a() versus instanceof

2009-12-18 Thread Christopher Jones
Johannes Mueller wrote: if(is_a($foo, bar)){ .. } // runs with an undefined constant bar notification I think the instanceof solution can cause problems, because you can not trigger the problem. What do you think? I think you meant: if(is_a($foo, "bar")){ since is_a() takes a string as

Re: [PHP-DEV] is_a() versus instanceof

2009-12-18 Thread Johannes Schlüter
On Sat, 2009-12-19 at 01:42 +0100, Johannes Mueller wrote: > if($foo instanceof bar){ > .. > } > // runs without any notification instanceof is a language construct expecting a class identifier. It doesn't complain about on-existing classes as it would need to trigger the __autoloader which might

[PHP-DEV] is_a() versus instanceof

2009-12-18 Thread Johannes Mueller
Hi, is it intended to have different behaviours of is_a() and instanceof? Let's assume you have the following code snippets: class foo{} class baz{} //<-you have a typo here, want to write bar if($foo instanceof bar){ .. } // runs without any notification and if(is_a($foo, bar)){ .. } // run