note 25510 deleted from language.operators.comparison by sniper
| From: | sniper@php.net | Date: | Mon, 13 Oct 2003 00:17:10 +0000 |
| Subject: | note 25510 deleted from language.operators.comparison by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-58436@lists.php.net to get a copy of this message | ||
Note Submitter: s.leib@kopfteam.de
----
A good example for using the "===" operator. Check this out:
if (strpos($a, $b) === 0) { ... }
evaluates true exactly when $a *begins* with $b, i.e. if strpos returns Zero.
And why "===" ? Because if $b is not at all contained in $a, strpos will return
"false", which evaluates to "0" if compared to another numeric.
Now, "===" does not only compare the values but also the type, and since 'false'
is of a different type than "0", you'll get the result you expect. Cool, eh?
Have fun!
/sascha