Re: not_null function
| From: | Kris Craig | Date: | Sat, 05 Jul 2014 07:42:39 +0000 |
| Subject: | Re: not_null function | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-75258@lists.php.net to get a copy of this message | ||
>
>
>> Currently, this is what's available for checking a variable's status
>> without throwing any errors:
>>
>> Variable exists and !== NULL: isset( $var )
>> Variable === NULL or doesn't exist: !isset( $var )
>> Variable == NULL or doesn't exist: empty( $var )
>> Variable exists and != NULL: !empty( $var )
>> Variable exists (including NULL): ????
>>
>
> Yep, nothing exists for that; we have a whole bunch of
>
_exists()
> functions, but not e.g. variable_exists() or even a dedicated
> exists
> opcode.
>
>
>> Variable exists and === NULL: ????
>>
>
> That's simply @$var === null or
> @is_null($var) of course ;-)
>
Is there any practical reason that you know of why 'exists' doesn't exist
(maybe there's some reason why it shouldn't)? Or is it just something that
never came up? If the latter, I wonder if there'd be any support for
changing that.
--Kris