Re: PHP 7.1 - Address PHPSadness #28?

From: Date: Wed, 26 Aug 2015 15:06:55 +0000
Subject: Re: PHP 7.1 - Address PHPSadness #28?
References: 1 2 3 4 5  Groups: php.internals 
Request: Send a blank email to internals+get-87933@lists.php.net to get a copy of this message
Craig Francis wrote on 26/08/2015 14:53:
On 26 Aug 2015, at 12:36, Rowan Collins <rowan.collins@gmail.com> wrote:
Fortunately, the function you are looking for already exists: http://php.net/array_key_exists
It does, although I seem to have edited that out of my reply... was trying to keep it short ;-)
You could have kept the reply even shorter by omitting examples for which the language already provides the solution ;)
At the moment I'm out of examples (bit busy at the moment), but I do know that when I'm doing an isset() check, I'm really wanting to know if the variable (or key) exists
Stop. As soon as you say "or key" you completely defeat your argument. The whole thing is ONLY worth discussing if you can come up with an example of an actual variable having unknown existence.
where NULL may be a perfectly valid value.
It's not that NULL isn't a valid value; it's that "doesn't exist" isn't a meaningful state for a variable. It's like checking if the current line number is greater than 100, it shouldn't mean anything to the compiled program. See the SO answer I linked earlier for more thought experiments along these lines. Regards, -- Rowan Collins [IMSoP]

« previous php.internals (#87933) next »