Welcome! Log In Create A New Profile

Advanced

[PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()

Posted by Nikita Popov 
On Fri, May 4, 2012 2:10 pm, Kris Craig wrote:
> On Fri, May 4, 2012 at 11:48 AM, Richard Lynch <[email protected]> wrote:
>
>> On Wed, May 2, 2012 4:43 am, Pierre Joye wrote:
>> >>> empty() on the other hand, tests if something is empty, and only
>> if
>> >>> it
>> >>> is empty. The result of an expression can be empty.
>> >>>
>> >>
>> >> an expression can also have a value of null.
>> >
>> > And NULL is empty. No issue here.
>>
>> Expressions can also return "", 0, 0.0, "0", array()
>>
>> You really think those should all be empty?
>>
>
> Unless I'm missing something here, aren't all those things already
considered to be empty?? Here's what the PHP man page for empty()
says:
>
> The following things are considered to be empty:
>
> - *""* (an empty string)
> - *0* (0 as an integer)
> - *0.0* (0 as a float)
> - *"0"* (0 as a string)
> - *NULL*
> - *FALSE*
> - *array()* (an empty array)
> - *var $var;* (a variable declared, but without a value in a class)

I am suggesting that some of those wouldn't make so much sense being
"empty" in an expression.

empty(2.0 - 1.9999999999999);

Might not be 0.0, but that's not the point.

For some not-empty values added or subtracted, more or less at the
whims of digital float behave would or wouldn't be empty.

Furthermore, empty on "0" was originally designed user input via
GET/POST so that an <option>0</option> would be empty()

--
brain cancer update:
http://richardlynch.blogspot.com/search/label/brain%20tumor
Donate:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FS9NLTNEEKWBE




--
brain cancer update:
http://richardlynch.blogspot.com/search/label/brain%20tumor
Donate:
https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FS9NLTNEEKWBE



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
Sorry, only registered users may post in this forum.

Click here to login