note 109373 added to language.operators.comparison
| From: | toader_alexandru at yahoo dot com | Date: | Wed, 11 Jul 2012 13:56:55 +0000 |
| Subject: | note 109373 added to language.operators.comparison | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-189100@lists.php.net to get a copy of this message | ||
it looks that
if you check 0 against a string with == then PHP returns true:
php -r 'var_dump(0 == "statuses");'
-> returns TRUE
but not if your string has a number at the beginning:
php -r 'var_dump(0 == "2statuses");'
-> returns FALSE
from the specs I get it that it attempts a conversion - in this case the string to number.
so better use ===
as always :)
----
Server IP: 69.147.83.197
Probable Submitter: 89.30.119.55
----
Manual Page -- http://www.php.net/manual/en/language.operators.comparison.php
Edit -- https://master.php.net/note/edit/109373
Del: integrated -- https://master.php.net/note/delete/109373/integrated
Del: useless -- https://master.php.net/note/delete/109373/useless
Del: bad code -- https://master.php.net/note/delete/109373/bad+code
Del: spam -- https://master.php.net/note/delete/109373/spam
Del: non-english -- https://master.php.net/note/delete/109373/non-english
Del: in docs -- https://master.php.net/note/delete/109373/in+docs
Del: other reasons-- https://master.php.net/note/delete/109373
Reject -- https://master.php.net/note/reject/109373
Search -- https://master.php.net/manage/user-notes.php