The error suppression was discussed in the rfc and yes it is not clean and
you could be suppressing something else inadvertently.

Yes the false value would be an issue with this, but for 0, empty array and
empty string is an issue with just about anything else in PHP already. Hence
=== if you want to be strict with it.

2009/5/12 Olivier B. <php-dev.l...@daevel.net>

> So if the variable is set and contains "false", we can't check it ?
> And near same problem for 0, empty array and empty string.
>
> But you can also use this syntax : (yes it's not very "clean")
>
>   if( @$_GET['foo'] === 'bar')
>   or
>   if( @$_GET['foo'] === 'bar' or @$_GET['baz'] === 'bat' )
>
>
> Olivier
>
> Ólafur Waage a écrit :
>
>> While researching for this suggestion I found this rfc proposal regarding
>> ifsetor() ( 
>> http://wiki.php.net/rfc/ifsetor?s[]=isset<http://wiki.php.net/rfc/ifsetor?s%5B%5D=isset>
>> <http://wiki.php.net/rfc/ifsetor?s%5B%5D=isset>)
>> and it's rejection point was that it was currently not possible (
>> http://marc.info/?l=php-internals&m=108931281901389&w=2 )
>>
>> But would it be possible to check for a value of a variable if it is set?
>>
>> Since I often do (and see others do)
>>
>> if(isset($_GET["foo"]) && $_GET["foo"] == "bar")
>> or even worse
>> if((isset($_GET["foo"]) && $_GET["foo"] == "bar") || (isset($_GET["baz"])
>> &&
>> $_GET["baz"] == "bat"))
>>
>> to be able to do something like this
>>
>> if(isset($_GET["foo"]) == "bar")
>> or
>> if(isset($_GET["foo"]) == "bar" || isset($_GET["baz"]) == "bat")
>>
>> That isset (or some other language construct) would return the variable if
>> it were set and false if it was not.
>>
>> Thanks for your time, i know this has probably been talked to death in one
>> form or other.
>>
>> Ólafur Waage
>> olaf...@gmail.com
>>
>>
>>
>

Reply via email to