Re: isset(), undefined variables, and null
- From: arundelo@xxxxxxxxxxx
- Date: Mon, 02 Jul 2007 21:13:01 -0700
Norm:
No... !isset($Foo) determines if $Foo is ok to evaluate.
When I say "safe to evaluate", I mean it in exactly the
sense of the the first sentence of the original post:
Is there a way to tell whether accessing a variable will
result in an "Undefined variable" E_NOTICE?
Norm:
$dump = array_key_exists('Foo',$GLOBALS) ? var_dump($Foo)
: 'Not safe to evaluate.';
should be what you're looking for, No?
Doesn't work if $Foo is local. The get_defined_vars()
solution upthread does exactly what I what I was seeking,
despite its kluginess. So does your error_get_last() idea
mentioned downthread (this is a variation on my solutions
from the original post).
I'd like to see how your using this...
Oh, I'm not using it; I just realized that isset()'s
behavior is, IMHO, broken, and I was curious if there was
something that did what I thought isset() should do. (In
the actual situation that inspired my curiosity, I wanted to
know whether it was safe to evaluate $Foo['Bar'], but
array_key_exists('Bar', $Foo) works fine for that.)
Thanks,
--
Aaron
http://arundelo.com/
.
- Follow-Ups:
- Re: isset(), undefined variables, and null
- From: Norman Peelman
- Re: isset(), undefined variables, and null
- References:
- Re: isset(), undefined variables, and null
- From: arundelo
- Re: isset(), undefined variables, and null
- From: Norman Peelman
- Re: isset(), undefined variables, and null
- From: arundelo
- Re: isset(), undefined variables, and null
- From: Norman Peelman
- Re: isset(), undefined variables, and null
- Prev by Date: Re: isset(), undefined variables, and null
- Next by Date: Re: IMAP PHP - Reading contents of 200+ emails
- Previous by thread: Re: isset(), undefined variables, and null
- Next by thread: Re: isset(), undefined variables, and null
- Index(es):
Relevant Pages
|