note 51113 added to function.isset
| From: | yaogzhan at gmail dot com | Date: | Sun, 20 Mar 2005 12:52:14 +0000 |
| Subject: | note 51113 added to function.isset | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-86713@lists.php.net to get a copy of this message | ||
in PHP5, if you have
<?PHP
class Foo
{
protected $data = array('bar' => null);
function __get($p)
{
if( isset($this->data[$p]) ) return $this->data[$p];
}
}
?>
and
<?PHP
$foo = new Foo;
echo isset($foo->bar);
?>
will always echo 'false'. because the isset() accepts VARIABLES as it parameters, but in
this case, $foo->bar is NOT a VARIABLE. it is a VALUE returned from the __get() method of the
class Foo. thus the isset($foo->bar) expreesion will always equal 'false'.
----
Manual Page -- http://www.php.net/manual/en/function.isset.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51113
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51113&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51113&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51113&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51113&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51113&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51113&report=yes
Search -- http://master.php.net/manage/user-notes.php