Date: 04/18/00
- Next message: Andrei Zmievski: "Re: [PHP-DEV] Clearing the PHP Output Buffer"
- Previous message: Bug Database: "[PHP-DEV] PHP 4.0 Bug #4175 Updated: new class_name doesn't work in class definition"
- In reply to: Andrei Zmievski: "Re: [PHP-DEV] PHP 4.0 Bug #4173: add function property_exists() please"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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>
- Next message: Andrei Zmievski: "Re: [PHP-DEV] Clearing the PHP Output Buffer"
- Previous message: Bug Database: "[PHP-DEV] PHP 4.0 Bug #4175 Updated: new class_name doesn't work in class definition"
- In reply to: Andrei Zmievski: "Re: [PHP-DEV] PHP 4.0 Bug #4173: add function property_exists() please"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

