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.

By Jack Slingerland

Founder of Working and living in Raleigh, NC. I manage a team of software engineers and work in Python, Django, TypeScript, Node.js, React+Redux, Angular, and PHP. I enjoy hanging out with my wife and son, lifting weights, and advancing in my free time.