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?

查看全部
duanke6249
duanke6249
2018/09/27 22:13
  • php
  • decimal
  • int
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

2个回复