Home >Backend Development >PHP Tutorial >How to get page execution time in PHP

How to get page execution time in PHP

巴扎黑
巴扎黑Original
2016-12-22 14:43:511045browse

Some loop code, sometimes you want to know the execution time of the page, you can add the following lines of code to the head and tail of the page:

Head:

<?php
$stime=microtime(true);

Tail:

$etime=microtime(true);//获取程序执行结束的时间
$total=$etime-$stime;  //计算差值
?>

Final output:

echo "<br />当前页面执行时间为:{$total} 秒";


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