|
Posted by arundelo on 07/03/07 04:13
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/
Navigation:
[Reply to this message]
|