Function Params for Multiple Type Hinting
// Multiple type hinting in one parameter
function myage(int|float|string $age){
echo $age;
}
myage("forty eight");
Here the $age parameter can be integer, float or string.
by dev
Function Params for Multiple Type Hinting
// Multiple type hinting in one parameter
function myage(int|float|string $age){
echo $age;
}
myage("forty eight");
Here the $age parameter can be integer, float or string.
by dev
Type Hinting
// Type Hinting - int, float, bool, string
function myage(int $age){
echo $age."\n";
}
myage(5);