note 66245 added to language.operators.comparison
| From: | Alex at osu1 dot php dot net | Date: | Wed, 17 May 2006 14:49:48 +0000 |
| Subject: | note 66245 added to language.operators.comparison | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-111509@lists.php.net to get a copy of this message | ||
I think everybody should read carefully what "jeronimo at DELETE_THIS dot transartmedia dot
com" wrote. It's a great pitfall even for seasoned programmers and should be looked upon
with a great attention.
For example, comparing passwords with == may result in a very large security hole.
I would add some more to it:
The workaround is to use strcmp() or ===.
Note on ===:
While the php documentation says that, basically,
($a===$b) is the same as ($a==$b && gettype($a) == gettype($b)),
this is not true.
The difference between == and === is that === never does any type conversion. So, while, according
to documentation, ("+0.1" === ".1") should return true (because both are strings
and == returns true), === actually returns false (which is good).
----
Server IP: 212.124.37.9
Probable Submitter: 85.117.48.90
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/language.operators.comparison.php
Edit -- http://master.php.net/note/edit/66245
Del: integrated -- http://master.php.net/note/delete/66245/integrated
Del: useless -- http://master.php.net/note/delete/66245/useless
Del: bad code -- http://master.php.net/note/delete/66245/bad+code
Del: spam -- http://master.php.net/note/delete/66245/spam
Del: non-english -- http://master.php.net/note/delete/66245/non-english
Del: in docs -- http://master.php.net/note/delete/66245/in+docs
Del: other reasons-- http://master.php.net/note/delete/66245
Reject -- http://master.php.net/note/reject/66245
Search -- http://master.php.net/manage/user-notes.php