Source Code:
(back to article)
<?php $var1 = "3.14159"; $var2 = 42; $var3 = true; $var4 = "not a number"; echo doubleval($var1) . "\n"; // output: 3.14159 echo doubleval($var2) . "\n"; // output: 42.0 echo doubleval($var3) . "\n"; // output: 1.0 (true is converted to 1.0) echo doubleval($var4) . "\n"; // output: 0.0 (cannot convert "not a number" to a double) ?>
Result:
Report an issue