In PHP, the standard equality comparison operator is '=='. This is used for both strings and numbers (compare this to Perl's '==' and 'eq'). However, there is another equality operator in PHP, '===' (that's right, three equal signs) that will enforce type checking i.e.97 == "97" // returns true
97 === "97" // returns false as you are comparing an integer to a string
In a similar fashion, there is a '!==' that enforces type checking.
There are times (more often than you would think) that these operators should be used when compared to there un-strict equivilents.
Just your friendly, neighborhood Spiderma...errr... PHP tip-dropper.
| J$ |
|
Comments