Categories
PHP Programming

PHP Type Evaluation

Aside from grad school drama, I learned something new the other day about PHP.  In PHP, there are two ways to look for equality: “==” and “===”.

$a = “1”;
$b = 1;
if($a == $b) { echo “True”; } else { echo “False”; }
if($a === $b) { echo “True”; } else { echo “False”; }

The first if statement would evaluate to true because it only evaluates the value.  The second if statement would evaluate to false, because it evaluates both value AND type.