<?php
$var = NULL;
var_dump(isset($var)); // bool(false)
var_dump(isset($unset_var)); // bool(false)
?>
isset($var) should return TRUE, since it has been set to NULL.
Is there any way to check for this?
Thanks!
<?php
$var = NULL;
var_dump(isset($var)); // bool(false)
var_dump(isset($unset_var)); // bool(false)
?>
isset($var) should return TRUE, since it has been set to NULL.
Is there any way to check for this?
Thanks!
use get_defined_vars() to get an array of the variables defined in the current scope and then test against it with array_key_exists();
Edited:
if you wanted a function to test existence you would create one like so:
function varDefined($name,$scope) {
return array_key_exists($name, $scope);
}
and use like so in any given scope:
$exists = varDefined('foo',get_defined_vars());
Should work for any scope.