Re: PHP 4.0 Bug #4173: add function property_exists() please
| From: | PER4MANCE, J. Dolecek | Date: | Tue, 18 Apr 2000 13:21:39 +0000 |
| Subject: | Re: PHP 4.0 Bug #4173: add function property_exists() please | ||
| References: | 1 2 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-18008@lists.php.net to get a copy of this message | ||
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