CKTIS / PHP
Equality of type and value (===)
For objects, test whether both variables refer to the same instance. Separate instances with identical properties are distinct.
Version: PHP 8.4; repository runtime, production runtime not attested
Syntax
$left === $rightFor objects, test whether both variables refer to the same instance. Separate instances with identical properties are distinct.
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.
4 === "4"→false0 === false→false[1,2] === [1,2]→true$box === clone $box→false
Examples
<?php
echo json_encode(4 === "4"), PHP_EOL;
echo json_encode(0 === false), PHP_EOL;
echo json_encode([1,2] === [1,2]), PHP_EOL;
$box = (object)['id'=>4];
echo json_encode($box === clone $box), PHP_EOL;
Result
false false true false