html靜態頁具體實現思路,帶實例!!

       今天做項目用到php的靜態化處理,甚是頭疼。到底怎麼能夠簡單的實現php的靜態化處理呢,靈光一現想到了php的函數ob_start() 和 ob_get_content();

       下面是具體的思路,代碼雖短但是代表的是一種思想!!

       程序行業,其它次之,思想第一!!!

       代碼如下

  1. <?php 
  2. ob_start(); 
  3. ?> 
  4. <html> 
  5.   <head> 
  6.         <title>this is a  html example!!!</title> 
  7.   </head> 
  8.   <body> 
  9.     this is a  html example!!!this is a  html example!!!this is a  html example!!!this is a  html example!!!this is a  html example!!!this is a  html example!!!this is a  html example!!!this is a  html example!!!this is a  html example!!!this is a  html example!!!this is a  html example!!!this is a  html example!!!this is a  html example!!!this is a  html example!!!this is a  html example!!!this is a  html example!!!this is a  html example!!! 
  10.   </body> 
  11. </html> 
  12.  
  13. <?php  
  14. $html = ob_get_contents(); 
  15.  
  16. $fp = fopen('./htm.html',"w"); 
  17.  
  18. fwrite($fp,$html); 
  19.  
  20. fclose($fp); 
  21. ?> 
  22.  
  23. 放到你的www目錄下嘗試下吧!!這就是簡單的html實現思路!! 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章