CKTIS / PHP
Difference in type or value (!==)
Distinguish a search result from its failure marker. Strict inequality with false accepts a valid zero result as well.
Version: PHP 8.4; repository runtime, production runtime not attested
Syntax
$left !== $rightDistinguish a search result from its failure marker. Strict inequality with false accepts a valid zero result as well.
Scalar types are preserved. An integer and a string containing its digits are different. This lets a search result distinguish index zero from the boolean value false.
0 !== false→true4 !== 4.0→truenull !== null→falsearray_search('A', ['A'], true) !== false→true
Examples
<?php
echo json_encode(0 !== false), PHP_EOL;
echo json_encode(4 !== 4.0), PHP_EOL;
echo json_encode(null !== null), PHP_EOL;
echo json_encode(array_search('A', ['A'], true) !== false), PHP_EOL;
Result
true true false true