Scott Arciszewski wrote on 26/08/2015 04:09:
Hi everybody,
Would anyone be interested in adding another helper like
isset()/empty() simply called exists() which would return true if the
variable is defined in the current scope (i.e. without raising an
E_NOTICE)?
My answer to this would be a very loud "no".
I have written at length about this on StackOverflow:
http://stackoverflow.com/a/18646568/157957
In short, if your algorithm relies on knowing whether, anywhere in the
preceding scope, a variable has been implicitly "declared" (in as much
as that concept has any meaning in PHP), that algorithm is broken. If it
relies on knowing whether a variable has been changed from its initial
state, then isset() will do exactly what you want.
Note that many people looking for examples of this "problem" start
mentioning array keys and object properties; we have functions for
checking existence of those, so please don't waste time on such examples.
Regards,
--
Rowan Collins
[IMSoP]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php