为什么PHP以科学记数法打印我的号码,当我指定它为.000021? [英] Why is PHP printing my number in scientific notation, when I specified it as .000021?
本文介绍了为什么PHP以科学记数法打印我的号码,当我指定它为.000021?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<?PHP
$ var = .000021;
echo $ var;
?>
输出是2.1E-5!
为什么呢?它应该打印.000021
解决方案
使用 同时检查 sprintf() In PHP I have the following code: the output is 2.1E-5 ! Why? it should print .000021 Use number_format() to get what you're after: Also check sprintf() 这篇关于为什么PHP以科学记数法打印我的号码,当我指定它为.000021?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
print number_format($ var,nofollow noreferrer> number_format 5);
<?PHP
$var = .000021;
echo $var;
?>
解决方案 print number_format($var, 5);
查看全文