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

How to get page execution time in PHP

巴扎黑
Release: 2023-03-03 22:58:02
Original
987 people have browsed it

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);
Copy after login

Tail:

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

Final output:

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


Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template