Re: isset(), undefined variables, and null


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?


$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.)




Relevant Pages

  • Re: isset(), undefined variables, and null
    ... sense of the the first sentence of the original post: ... : 'Not safe to evaluate.'; ... How would you find 'Foo' given $Foo? ... That being said, isset() works as expected. ...
  • Re: For iPod Photo users...
    ... >>The only 'safe' place for data is on a dvd r x 2, ... I carry it in the same bag that I lug around ... > Did anybody even actually *read* my original post? ... > are right - what a grumpy bunch some in this group have become. ...
  • Re: Hi all
    ... Duncan Snowden did eloquently scribble: ... getting at is that trolls really aren't safe around here. ... My original post was ...
  • Re: futurama
    ... Andrew Ryan Chang wrote: ... >>> I think it's safe to assume I'm talking about the original post. ... > post Mr. Stabby was replying to. ...
  • Re: Multithreaded MEX file
    ... I already suspected that some parts of Matlab's C API would be safe to ... since my original post I have ... I am not even able to single step in the debugger into the mexPrintf ...