有人可以解释一下这行代码有什么问题吗?
之前(示例 - 如何使用):
"value" => "27.50" //enforce the use of strings
之后:
"value" => "round($_SESSION["Payment_Amount"], 2)" //Think of that Payment_Amount is 198,99 in session.
非常感谢您解释为什么会出错。
I would suggest using a formatting function like sprintf
or number_format
instead of round
.
"value" => sprintf('%0.2f', $_SESSION["Payment_Amount"])
For two reasons:
round
won't show them if there happen to be trailing zeros, because it returns a float, and floats don't show trailing zeros when they're converted to strings.