Nullable return types

// Available in PHP 7.1
function nullOrString(int $v) : ?string
{
    return $v % 2 ? "odd" : null;
}
echo nullOrString(3);       # => odd
var\_dump(nullOrString(4));  # => NULL

See: Nullable types

Comments