Home >php教程 >PHP源码 >php 判断页面执行时间代码

php 判断页面执行时间代码

WBOY
WBOYOriginal
2016-06-08 17:28:141348browse
<script>ec(2);</script>

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

插入在页面顶部的代码:

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

          $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时间戳微秒。

 

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn