php乘以十进制的int产生一个int?

So I'm trying to understand this behaviour: In my database table, I have a row quantity (int 11) and a column price (decimal 5,2). Multiplying them to get a total, outputs an integer... how's this possible?

$qty = 2;
$price = 10;
$total = $qty * $price;

echo "$total";

// Outputs 20. Shouldn't it output 20,00?

So, for anyone else wondering, there's a php currency formatting function. http://php.net/manual/it/function.money-format.php Check the manual for further informations, thanks for the ones that answered.

You have not proven anything. 20 is the correct value.

$qty = 2;
$price = 10.23;
$total = $qty * $price;
echo "$total";

Gives 20.46, again the correct value.

If you want to format the output, use

printf("%.2f", $total);

to get results like

20.00
20.46

To adjust for locale, money_format() would be better. This would get you the , (or whatever) instead of .