Answer the question
In order to leave comments, you need to log in
How to distinguish a variable declared as null from an undeclared variable?
How to distinguish a variable declared as null from an undeclared variable?
$a = null;
var_dump(isset($a)); // false
var_dump(isset($a)); // false
Answer the question
In order to leave comments, you need to log in
php.net/manual/en/function.is-null.php
<?php
error_reporting(E_ALL);
set_error_handler('eh');
function eh($severity, $message, $filename, $lineno) {
if (error_reporting() == 0) {
return;
}
if (error_reporting() & $severity) {
throw new ErrorException($message, 0, $severity, $filename, $lineno);
}
}
//$abc=NULL;
try {
if($abc===NULL) echo 'NULL';
} catch (Exception $e) {
echo 'NOT DEFINED';
}
?>
<?php
error_reporting(E_ALL);
//$abc=NULL;
if(array_key_exists('abc',get_defined_vars())) var_dump($abc);
else echo 'NOT DEFINED';
?>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question