I've become a little confused, when my server calculates strings like this:
$var1 = "0.5";
$var2 = "0.7";
echo $var1 + $var2;
I sometimes get the answer 0 and sometimes I get the correct 1.2!
When I get 0 I try to change it to this:
$var1 = "0,5";
$var2 = "0,7";
echo $var1 + $var2;
and I get the correct answer 1,2
I've come to the conclusion now that it depends on the setlocale function!
If I set it to: setlocale(LC_ALL, "swedish");
The calculations wants a ,
if set to: setlocale(LC_ALL, "english");
it wants the .
Is this the way it should be!??
When reading the manual:
http://se.php.net/manual/en/language.types.string.php#language.types.string.conversion
It states:
The string will evaluate as a float if it contains any of the characters '.', 'e', or 'E'. Otherwise, it will evaluate as an integer.