Re: [PHP-DEV] PHP 4.0 Bug #4173: add function property_exists() please From: PER4MANCE, J. Dolecek (jdolecek <email protected>)
Date: 04/18/00

Andrei Zmievski wrote:
> > There are bunch of FOO_exists() functions to check for existence of functions, class > > methods and such. There is no way to check if an object has given attribute, though.
> > It's easy to do in PHP:
> >
> > # return true if property exists in given object
> > # boolean property_exists(Object obj, string name)
> > function
> > property_exists($obj, $name) {
> > $attrs = get_object_vars($obj);
> > return isset($attrs[$name]);
> > }
> >
> > but this should be core PHP function.
>
> Why? You can very easily do this:
>
> if (isset($obj->$name)) { .. }

Ah, obvious :) Thanks for pointing out. The PR can be closed then.

Jaromir

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>