首頁  >  文章  >  php教程  >  php 生成html文件代码

php 生成html文件代码

WBOY
WBOY原創
2016-06-08 17:29:551466瀏覽

本款程序是一款简单的php生成 html文件的源码代码哦,只涉及到模板与写简单的内容哦,如果要涉及到数据库思路上差不多了。

<script>ec(2);</script>

 $template_file = "template_art.html";
 if( file_exists($template_file) ){
  $mb = file_get_contents($template_file);    
  if( !empty($mb) ){
   
   for( $i=1;$i     $temp = makehtml($mb);
    $handle = fopen($i.".html",'w+');   
    if( fwrite($handle,$temp)){  
     echo("创建文件$i.html成功
");
    }else{
     echo('文件不可写状态!');
    }
   }
   fclose($handle);   
  }else{
    die('read template fail');
  }
 }else{
  die('Template file not exists');
 }
 
 function makehtml($str){
  $array = array('{dxh}menu{/dxh}','{dxh}content{/dxh}','{dxh}hot{/dxh}','{dxh}down{/dxh}','{dxh}help{/dxh}','{dxh}school{/dxh}');
  $Rarray = array('菜单','内容','热点','下载','帮助','学院');
  $str = str_replace($array,$Rarray,$str);
  return $str;
 }

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn