我想在 PHP 中显示分数。为此我写道:
$a = 3;
$b = 2;
$c = "$a/$b";
echo $c; // this displays 3/2
but on the other hand I want to multiply $c by an integer;
echo $c * 2; // this shows me an error
这就是我所看到的:(!)注意:遇到格式不正确的数值
有人能帮我吗?
尝试将单引号更改为双引号。不带引号,取决于您的期望。
然后尝试更改 $c 的类型。
Example:
$a = 3;
$b = 2;
$c = "$a/$b"; // or $c = $a/$b;
echo $c; // this displays 3/2
// but on the other hand I want to multiply $c by an integer;
echo (float)$c * 2; // this shows me an error
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)