On 01/09/2015 10:29, Craig Francis wrote:
Personally I still like the idea of an exists(), because I feel that is how 
many programmers treat and use the isset() function - simply because they do 
use NULL as a valid value, and either haven't read the manual, or forget the 
exception that is mentioned on line 1 (something I've done a couple of times).

I'm still not sure how exists() would be anything other than an alias for array_key_exists().

Once again, this is NOT about "using NULL as a valid value"; it's about "using a variable's NON-EXISTENCE as a valid state". I think that is the fundamental mistake people make - they think the "quirk" is that isset() returns false for a null value, when that is the most rational part of it. The "quirk" is that you don't get a warning when passing a completely undefined variable to isset().

Obviously, that's not something that's likely to change, but as you say, what we are really testing is "the value pointed at by some identifier". In an array, that identifier can be dynamic, but in plain variable scope, that identifier is something you the programmer have defined long before the program executed, so its existence is never in question.

Looked at that way, the handling of unitialised variables is just a side-effect of the handling of NULLs, since all unitialised variables have a default/implicit value of NULL.

Regards,

--
Rowan Collins
[IMSoP]


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to