为什么这个microtime在PHP中显得很奇怪

Jas*_*vis 9 php

为什么这个microtime在PHP中显得很奇怪

$start4 = microtime(true);
    // run some php code
$end4 = microtime(true);
print "Time4: ". ($end4 - $start4)."<br />"; 
Run Code Online (Sandbox Code Playgroud)

以上显示
:Time4:2.69412994385E-5

具有更复杂,更长时间运行过程的东西显示如下:
Time1:0.000292062759399

gre*_*ama 16

E-5是科学记数法.当你将它与字符串值连接时似乎会发生.尝试使用number_format ......?

print "Time4: ". number_format($end4 - $start4, 10)."<br />";

//or use:               printf(".10f", $end - $start)
Run Code Online (Sandbox Code Playgroud)


Fra*_*kie 15

将长数字(非常小或非常大)转换为10的幂是正常的.E-5只是意味着所显示的数字乘以(10/10/10/10/10)这使得它非常少数.

0.000000000000123比1.23E-13(例如)更难阅读.

不过,如果您确实想以其他格式查看数字:

$start = microtime(true);
$end = microtime(true);
echo "Time: ", number_format($end - $start, 50);
Run Code Online (Sandbox Code Playgroud)

这将在显示的数字上添加50个十进制房屋.

希望能帮助到你!