[PHP] isset($a-b) even if $a-b = null
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! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] isset($a-b) even if $a-b = null
Olav Mørkrid schreef: 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! if (isset($a - b) $a - b != null) { echo yes; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] isset($a-b) even if $a-b = null
On 8/17/07, Olav Mørkrid [EMAIL PROTECTED] 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! Seems your asking for something similar to perl's exists() function.. Best I can come up with is... $a-b = null; if (is_null($a-b) || isset($a-b)) { print yes; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php