Re: isset(), undefined variables, and null



arundelo@xxxxxxxxxxx wrote:
Is there a way to tell whether accessing a variable will
result in an "Undefined variable" E_NOTICE? isset() almost
does this, but it also returns false if a variable is set to
null:

$SetNonNull = 0;
$SetNull = null;
var_dump(isset($SetNonNull)); // bool(true)
$Junk = $SetNonNull; // No error, as predicted by isset().
var_dump(isset($NotSet)); // bool(false)
$Junk = $NotSet; // Raises an E_NOTICE, as predicted by isset().
var_dump(isset($SetNull)); // bool(false)
$Junk = $SetNull; // No error -- how to predict?

I realize I could do this by e.g., doing @$Var and checking
afterwards using $php_errormsg or a custom error handler;
I'm hoping for something less klugey.

Thanks,

--
Aaron
http://arundelo.com/


I'm afraid you're out of luck with it. You could also inspect the symbol table directly via get_defined_vars, but that's ugly.

--
gosha bine

extended php parser ~ http://code.google.com/p/pihipi
blok ~ http://www.tagarga.com/blok
.