Available as of PHP 8.0.0, Union Type Declarations accept values of multiple different types, rather than a single type. Union type definitions are made using the pipe (|) to separate types.
function add(int|float $a, int|float $b): int|float
{
return $a + $b;
}
null types may be declared nullable by either using ?Type or Type1|Type2|null.void cannot be used as part of a union type declaration.