Using type conversion, you can convert the value of a variable to another type. This conversion is the same as the type conversion in C language. Just insert the temporary data type you want to convert in parentheses before the variable you want to type convert.
The second line of code means "take out the variable value stored in $totalqty, interpret it as a floating point type, and save it in $totalamount". The $totalamount variable will become a floating point type. The converted variable does not change its type, so $totalqty is still an integer type. |