|
Posted by arundelo on 06/29/07 16:42
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/
Navigation:
[Reply to this message]
|