Re: isset(), undefined variables, and null
- From: gosha bine <stereofrog@xxxxxxxxx>
- Date: Sat, 30 Jun 2007 12:38:08 +0200
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
.
- References:
- isset(), undefined variables, and null
- From: arundelo
- isset(), undefined variables, and null
- Prev by Date: Re: The structure of PHP/Web Application coding.
- Next by Date: Re: Array_merge() Question
- Previous by thread: Re: isset(), undefined variables, and null
- Next by thread: A small problem in running PHP4 under PHP5 - $row[fieldname]
- Index(es):