Home  >  Article  >  Backend Development  >  PHP Get Script Running Time_PHP Tutorial

PHP Get Script Running Time_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 10:35:431075browse

header("content-type:text/html;charset=utf-8");

//microtime— Returns the current Unix Timestamp and microseconds

$oldtime = microtime(true);

echo "The running time of this script is:";

$v=0;

for ($i = 0; $i

$v++;

}

$newtime =microtime(true);

//Get the time difference

$runtime = $newtime-$oldtime;

//Convert timestamp to string—var_export Output or return a string representation of a variable

$runtime=var_export($runtime);

//Intercept the string substr_count and calculate the number of occurrences of the string

$postion = substr_count($runtime, 'E');

$runtime = substr($runtime,0,$postion-1);

//Convert string value to floatfloatval — Get the floating point value of a variable

$runtime = floatval($runtime)/1000;

echo $runtime."seconds";

?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/742404.htmlTechArticleheader("content-type:text/html;charset=utf-8"); //microtime— Return Current Unix timestamp and microseconds $oldtime = microtime(true); echo "The time this script runs is:"; $v=0; for ($i...
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