Olav Mørkrid wrote:
> how do i test if a property of a stdclass object is set, even if its
> value is null, similar to how array_key_exists() works for arrays.
> 
> the following method fails:
> 
>   $a->b = null;
>   if(isset($a->b))
>     echo "yes";
> 
> and property_exists() seems only to work for defined objects.
> 
> hope someone can help. thanks!

You can try:
 unset($a-b)

Or change isset() to empty().

empty() catches more than isset() e.g. '' (empty string), false, 0 etc.
are considered "empty". Depending on your logic it can still be very
useful. It is a language construct rather than a function so it's also
efficient.

Col

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to