Dev Diaries WD logo Dev Diaries WD
PHP INTERVIEW · EP 01
PHP INTERVIEW · Episode 01

What’s the difference between == and ===?

Loose vs Strict Comparison

ep1_equal_operator.php
<?php
$number = "2";                 // a STRING

// Loose comparison — checks value only
$result = ($number == 2) ? "true" : "false";
echo "Loose  (==)  -> " . $result;   // true

// Strict comparison — checks value AND type
$result = ($number === 2) ? "true" : "false";
echo "Strict (===) -> " . $result;   // false
Output
Loose operator (==) true
Strict operator (===) false

Same values (2 vs "2") — only the type check flips the result.

Watch the full episode

Watch on YouTube