Re: PHP 7.1 - Address PHPSadness #28?
| From: | Rowan Collins | 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:You could have kept the reply even shorter by omitting examples for which the language already provides the solution ;)Fortunately, the function you are looking for already exists: http://php.net/array_key_existsIt does, although I seem to have edited that out of my reply... was trying to keep it short ;-)
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) existsStop. 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]