note 103603 added to function.isset
| From: | benallfree at gmail dot com | Date: | Fri, 22 Apr 2011 01:21:57 +0000 |
| Subject: | note 103603 added to function.isset | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-179068@lists.php.net to get a copy of this message | ||
isset() returns TRUE if a value is NULL. That seems wrong to me as there is no way to distinguish
between a value set to NULL and a truly undefined value.
If you have this problem inside a class, there is a fix:
class T
{
function has_attribute($att)
{
$props = get_object_vars($this);
return array_key_exists($att, $props);
}
}
$x = new T();
$x->foo_exists = 4;
var_dump($x->has_attribute('foo_exists')); // TRUE
var_dump($x->has_attribute('bar_exists')); // FALSE
----
Server IP: 69.147.83.197
Probable Submitter: 72.194.208.80
----
Manual Page -- http://www.php.net/manual/en/function.isset.php
Edit -- https://master.php.net/note/edit/103603
Del: integrated -- https://master.php.net/note/delete/103603/integrated
Del: useless -- https://master.php.net/note/delete/103603/useless
Del: bad code -- https://master.php.net/note/delete/103603/bad+code
Del: spam -- https://master.php.net/note/delete/103603/spam
Del: non-english -- https://master.php.net/note/delete/103603/non-english
Del: in docs -- https://master.php.net/note/delete/103603/in+docs
Del: other reasons-- https://master.php.net/note/delete/103603
Reject -- https://master.php.net/note/reject/103603
Search -- https://master.php.net/manage/user-notes.php