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
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 __
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
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
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
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