True¶
true has two usages, as PHP keyword : the opposite of false, as a boolean value and a special type for functions that may return a boolean, but not false.
true
as a type was introduced in PHP 8.2.
<?php
function foo($a) : true|A {
if ($a == 1) {
return true;
} else {
return new A();
}
}
?>
Related : Boolean, Type System, False