首页 > php代码 > php 判断页面执行时间代码

php 判断页面执行时间代码

确定了PHP脚本所需的时间执行正确的一微秒。

插入在页面顶部的代码:

<?php 
          $mtime = microtime(); 
          $mtime = explode(' ', $mtime); 
          $mtime = $mtime[1] + $mtime[0]; 
          $starttime = $mtime; 
?>
然后添加在页面底部的以下内容:

<?php 
          $mtime = microtime(); 
          $mtime = explode(" ", $mtime); 
          $mtime = $mtime[1] + $mtime[0]; 
          $endtime = $mtime; 
          $totaltime = ($endtime - $starttime); 
          echo 'This page was created in ' .$totaltime. ' seconds.'; 
?>

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

 



教程地址:http://www.phprm.com/code/3d3ced4463240c2a997c63b4a873b151.html

欢迎转载!但请带上文章地址^^

标签:none

发表留言