What am I missing here?
When I run:
$var = 2.34; print $var;
--> 2 is returned.
gettype($var);
-->"double"
So, why do I only get the integer value?
Not sure maybe its a PHP4 thing, I tried your code with PHP3 and it returned the correct value
Yep, it was a bug in PHP4.0 !
I was running it on Win2000 with IIS5. I now installed PHP3 and it works fine. The version of PHP4 that I was running, was the first release. Maybe this bug is fixed in one of the updates of PHP4.0?
Use printf!
printf("%.2f",$var) // will return 2.34
<untested> This can be used as a redeclaration of a variable. I.e. $var = printf("%.2f",$var) </untested>