note 22296 deleted from language.types.null by danbrown
| From: | danbrown@php.net | Date: | Tue, 19 May 2009 14:21:34 +0000 |
| Subject: | note 22296 deleted from language.types.null by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-155743@lists.php.net to get a copy of this message | ||
Note Submitter: alex at netflex dot nl
----
Hi,
Function for looking if it is a NULL
<?php
$var = NULL;
if (isnull("var")) {
echo "var===NULL\n";
} else {
echo "var!==NULL\n";
}
if (isnull("test")) { // give FALSE, test is not set
echo "test===NULL\n";
} else {
echo "test!==NULL\n";
}
$array['var'] = NULL;
if (isnull("var", $array)) {
echo "array['var']===NULL\n";
} else {
echo "array['var']!==NULL\n";
}
function isnull($var, $base = FALSE) {
if ($base===FALSE) {
$base = &$GLOBALS;
} elseif (!is_array($base)) {
return FALSE;
}
if ((array_key_exists($var, $base))&&($base[$var]===NULL)) {
return TRUE;
} else {
return FALSE;
}
}
?>