Return type declarations and float numbers?

Good day, we suppose we have a function to estimate something(discounts, VAT, etc.) and it is a function of distinction.

public function calc(array $prices) {

 $discount = 10;

 $total = array_sum($prices);

 $total = $total / 100 * $discount;

 return $total;
}


For such a function of ad type of the return value? because in the end we can get int or float.
March 19th 20 at 09:17
1 answer
March 19th 20 at 09:19
Solution
You can not declare the type or just declare a float

Example the return type is float

Find more questions by tags PHP