note 111768 added to language.types.boolean
| From: | geza at turigeza dot com | Date: | Tue, 26 Mar 2013 18:14:33 +0000 |
| Subject: | note 111768 added to language.types.boolean | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-194221@lists.php.net to get a copy of this message | ||
// someKey is a boolean true
$array = array('someKey'=>true);
// in the following 'false' string gets converted to a boolean true
if($array['someKey'] != 'false')
echo 'The value of someKey is '.$array['someKey'];
As a result the above will output nothing :)
if($array['someKey'] == 'false')
echo 'The value of someKey is '.$array['someKey'];
And the above will output
The value of someKey is 1
In short true == 'false' is true.
----
Server IP: 69.147.83.199
Probable Submitter: 92.24.11.67
----
Manual Page -- http://php.net/manual/en/language.types.boolean.php
Edit -- https://master.php.net/note/edit/111768
Del: integrated -- https://master.php.net/note/delete/111768/integrated
Del: useless -- https://master.php.net/note/delete/111768/useless
Del: bad code -- https://master.php.net/note/delete/111768/bad+code
Del: spam -- https://master.php.net/note/delete/111768/spam
Del: non-english -- https://master.php.net/note/delete/111768/non-english
Del: in docs -- https://master.php.net/note/delete/111768/in+docs
Del: other reasons-- https://master.php.net/note/delete/111768
Reject -- https://master.php.net/note/reject/111768
Search -- https://master.php.net/manage/user-notes.php