Fatal error: Uncaught TypeError: Unsupported operand types: string + float error comes when one of your variables is a string and another one is float.
Let’s say, we have the following code:
$Total = $Var1 + $Var2;
If this throws Fatal error: Uncaught TypeError: Unsupported operand types: string + float
error then simply add (float) before the variables and problem will be solved.
By doing this, we are just typecasting the variable to a float value. Hence the above line will look like:
$Total = (float)$Var1 + $Var2;
or
$Total = $Var1 + (float) $Var2;
or
$Total = (float)$Var1 + (float) $Var2;