note 72077 added to function.isset
| From: | beuc at beuc dot net | Date: | Mon, 01 Jan 2007 09:56:33 +0000 |
| Subject: | note 72077 added to function.isset | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-121162@lists.php.net to get a copy of this message | ||
Beware that the chk() function below creates the variable or the array index if it didn't
existed.
<?php
function chk(&$var) {
if (!isset($var))
return NULL;
else
return $var;
}
echo '<pre>';
$a = array();
var_dump($a);
chk($a['b']);
var_dump($a);
echo '</pre>';
// Gives:
// array
// empty
//
// array
// 'b' => null
?>
----
Server IP: 194.246.101.61
Probable Submitter: 82.238.35.175
----
Manual Page -- http://www.php.net/manual/en/function.isset.php
Edit -- https://master.php.net/note/edit/72077
Del: integrated -- https://master.php.net/note/delete/72077/integrated
Del: useless -- https://master.php.net/note/delete/72077/useless
Del: bad code -- https://master.php.net/note/delete/72077/bad+code
Del: spam -- https://master.php.net/note/delete/72077/spam
Del: non-english -- https://master.php.net/note/delete/72077/non-english
Del: in docs -- https://master.php.net/note/delete/72077/in+docs
Del: other reasons-- https://master.php.net/note/delete/72077
Reject -- https://master.php.net/note/reject/72077
Search -- https://master.php.net/manage/user-notes.php