0

我有:

$newscore = $score*.3

现在$newscore转储时显示:

(float)0.6 (float)-0.6

回显时:

0.6-0.6

首先,我怎样才能使 var 值就像0.6$score唯一的正数一样2?是否有转换为字符串或类似的东西。

其次,存储的值$newscore似乎没有传递给我的 SQL INSERT 函数,该函数是使用占位符方法设置的%d $newscore

4

1 回答 1

2

这对我来说很好,它会返回double(0.6)

$score = 2;
$newscore = $score * 0.3;

var_dump($newscore);

至于你的第二个问题,你应该在使用十进制数时使用%f而不是%d

于 2012-11-30T10:40:52.247 回答