php使用microtime(true)查看代码执行时间

Posted 无影飞絮剑

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php使用microtime(true)查看代码执行时间相关的知识,希望对你有一定的参考价值。

microtime() 函数返回当前 Unix 时间戳和微秒数。

      如果带个 true 参数, 返回的将是一个浮点类型

round() 取出小数点后 3 位

 $t1 = microtime(true);
 // ... 执行代码 ...
 $t2 = microtime(true);
 echo ‘耗时‘.round($t2-$t1,3).‘秒‘;

 

以上是关于php使用microtime(true)查看代码执行时间的主要内容,如果未能解决你的问题,请参考以下文章