Re: PHP 4.0 Bug #4173: add function property_exists() please
| From: | Andrei Zmievski | Date: | Tue, 18 Apr 2000 13:13:37 +0000 |
| Subject: | Re: PHP 4.0 Bug #4173: add function property_exists() please | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-18006@lists.php.net to get a copy of this message | ||
On Tue, 18 Apr 2000, dolecek@ics.muni.cz wrote:
> From: dolecek@ics.muni.cz
> Operating system: NetBSD (1.4X kernel, 1.4.1 userland)
> PHP version: 4.0 Release Candidate 1
> PHP Bug Type: Feature/Change Request
> Bug description: add function property_exists() please
>
> 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)) { .. }
-Andrei
* It's an emergent property of human minds to create. *