PHP 8 · Types and functions
Use union types
Accept more than one type for a parameter.
function id(int|string $value): int|string
{
return $value;
}
PHP 8 · Types and functions
Accept more than one type for a parameter.
function id(int|string $value): int|string
{
return $value;
}
Was this page helpful?