<?php
function nullOrString(int $foo) : ?string {
return $foo%2 ? "odd" : null;
}
$result1 = nullOrString(42);
//result is null, type: NULL
echo "result1 = ", $result1, ", ", gettype($result1), "\n";
$result2 = nullOrString(37);
//result is "odd", string
echo "result2 = ", $result2, ", ", gettype($result2);