计算网页运行时间

来源:互联网 发布:淘宝收藏店铺失败 编辑:程序博客网 时间:2024/04/28 01:51

一 代码

Php代码  收藏代码
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
  2. <html xmlns="http://www.w3.org/1999/xhtml">  
  3. <head>  
  4. <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />  
  5. <title>计算页面的运行时间</title>  
  6. <style type="text/css">  
  7. <!--  
  8. body,td,th {  
  9.     font-size: 13px;  
  10. }  下载 
  11. body {  
  12.     margin-left: 10px;  
  13.     margin-top: 10px;  
  14.     margin-right: 10px;  
  15.     margin-bottom: 10px;  
  16. }  
  17. -->  
  18. </style></head>  
  19. <body>  
  20. <div align="center">  
  21. <?php  
  22. function run_time()  
  23. {  
  24.     list($msec$sec) = explode(" ", microtime());  
  25.     return ((float)$msec + (float)$sec);  
  26. }  
  27.      $start_time = run_time();  
  28.      $time1 = strtotime(date"Y-m-d H:i:s"));  
  29.      $time2 = strtotime("2017-10-01 00:00:00");         //2009年国庆节  
  30.      $time3 = strtotime("2017-01-01 ");                 //2009年元旦  
  31.      $sub1 = ceil(($time2 - $time1) / 3600);            //60 * 60  
  32.      $sub2 = ceil(($time3 - $time1) / 86400);           //60 * 60 * 24  
  33.      $end_time = run_time();  
  34. ?>   
  35. <p>  
  36. </div>  
  37. <table width="500" height="502" border="0" cellpadding="0" cellspacing="0" background="images/bg.jpg">  
  38.   <tr>  
  39.     <td width="92" height="140">&nbsp;</td>  
  40.     <td width="287">&nbsp;</td>  
  41.     <td width="99">&nbsp;</td>  
  42.   </tr>  
  43.   <tr>  下载
  44.     <td height="95">&nbsp;</td>  
  45.     <td align="left" valign="top"><?php  echo "距离2009年国庆节还有<font color=red> $sub1 </font>小时!!!" ;  ?></td>  
  46.     <td>&nbsp;</td>  
  47.   </tr>  
  48.   <tr>  
  49.     <td height="50">&nbsp;</td>  
  50.     <td align="left" valign="top"><?php  echo "距离2009年元旦还有<font color=red>$sub2 </font>天!!!"; ?></td>  
  51.     <td>&nbsp;</td>  
  52.   </tr>  
  53.   <tr>  
  54.     <td height="215">&nbsp;</td>  
  55.     <td align="left" valign="top">本示例的运行时间为<font color=blue> <?php echo ($end_time - $start_time); ?> </font>秒</td>  
  56.     <td>&nbsp;</td>  
  57.   </tr>  
  58. </table>  
  59. </body>  
  60. </html>  

 下载

二 运行结果
0 0
原创粉丝点击