You are here: Re: Test for the existence of a null property « PHP Programming Language « IT news, forums, messages
Re: Test for the existence of a null property

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация