I searched on StackOverflow and Google and I can't find the answer to this question:
Should we always use the triple equal in PHP for validation?
For example, I have a variable:
$x = '1';
if($x == 1) // will work
if($x === 1) // will not
Now, my point is if we need to validate numeric fields like:
if(is_numeric($x) && $x == '1') {
will be the equivalent to if($x === 1)
Since ===
also validate the type, will it be better if we always use the ===
?
From http://me.veekun.com/blog/2012/04/09/php-a-fractal-of-bad-design/
See http://habnab.it/php-table.html
And http://phpsadness.com/sad/47
And http://developers.slashdot.org/comments.pl?sid=204433&cid=16703529
That being said, when you are absolutely sure type is not an issue when you are creating simple expressions, == works well enough in my experience. Just be vigilant.