CKTIS / PHP
Inequality with type conversion (<>)
The angle-bracket spelling produces the same result as `!=`. It returns false for zero and the boolean false because those values are loosely equal.
Version: PHP 8.4; repository runtime, production runtime not attested
Syntax
$left <> $rightThe angle-bracket spelling produces the same result as !=. It returns false for zero and the boolean false because those values are loosely equal.
PHP compares a number and a numeric string by their numeric values. Leading zeros in a numeric string therefore cannot distinguish identifiers. Compare strings strictly when those zeros matter.
0 <> false→false8 <> "08"→false"07" <> "A7"→true
Examples
<?php
echo json_encode(0 <> false), PHP_EOL;
echo json_encode(8 <> "08"), PHP_EOL;
echo json_encode("07" <> "A7"), PHP_EOL;
Result
false false true