0

I have:

$newscore = $score*.3

Now the $newscore when dumped shows:

(float)0.6 (float)-0.6

when echoed:

0.6-0.6

Firstly how can I make the var value just 0.6 as the $score is only positive 2? Is there a convert to string or something like that.

Secondly the stored value in $newscore does not seem to pass to my SQL INSERT function which is setup using placeholder method %d $newscore.

4

1 に答える 1

2

This works fine for me, it returns double(0.6)

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

var_dump($newscore);

As for your second question, you should use %f instead of %d when using decimal numbers

于 2012-11-30T10:40:52.247 に答える