This article mainly introduces the code optimization of PHP, which has certain reference value. Now I share it with everyone. Friends in need can refer to it
Locating slow code locations
<?php //程序运行时间 $starttime = explode(' ',microtime()); echo microtime(); /*········以下是代码区·········*/ for($i=0;$i<1000000;$i++){ $i; } /*········以上是代码区·········*/ //程序运行时间 $endtime = explode(' ',microtime()); $thistime = $endtime[0]+$endtime[1]-($starttime[0]+$starttime[1]); $thistime = round($thistime,3); echo "本网页执行耗时:".$thistime." 秒。".time(); ?>
The above is the detailed content of PHP code optimization. For more information, please follow other related articles on the PHP Chinese website!