|
Posted by wildernesscat on 08/09/06 06:35
Hi Marcin,
>From my experience, the is_a() function does not work unless the object
has been created explicitly using its class name (Foo in your example).
If the object has been created via StdClass, is_a() doesn't recognize
it.
As for using get_class_vars(), I'm getting into O(n2) here. You
suggested that I scan the properties of one object and compare them to
the other one, right? I was looking for a O(n) solution.
Regards,
Danny
> I think this is VERY different from what you asked in the first mail.
> But to do that, you want something like this:
>
> class Foo (
> function Foo() {}
> }
>
> $f = new Foo();
> ...
> if (is_a($f, 'Foo')) {
> echo "yes";
> }
> ...
> echo "\$f is of type: " . get_class($f);
>
> To do what you asked before (and hence break some main concepts in
> OO), you can:
>
> $vars = get_class_vars('Foo');
Navigation:
[Reply to this message]
|