当前位置:编程学习 > php >>

php简单生成html静态页面代码

这是一款我自己没事时写的一款简单的把php文件生成html静态页面的程序代码哦,就是用str_replace来替换函数返回的数据就OK了。

$fileName = md5_filename($rs[0],$rs['z_a'],$rs['filesendid']);
   $path = get_path($rs['sysa']).$rs['z_a'].'/';
     
   $parent = $_SERVER["DOCUMENT_ROOT"];//substr(getcwd(),0,strrpos(getcwd(),'\'));  
    
   $filePath = $parent.'\'.$path;
   $tempLate = str_replace('{path}',path($rs['z_a'],$rs['sysa']),$fileContent);
   $tempLate = str_replace('{htmlAbout}',htmlAbout($rs['z_a'],10,8,0,''),$tempLate);   
   $tempLate = str_replace('{htmlTemplate}',htmlTemplate(0),$tempLate);
   $tempLate = str_replace('{htmlMenu}',htmlMenu($rs['sysa']),$tempLate);
   $tempLate = str_replace('{htmlHelp}',htmlHelp($rs['sysa']),$tempLate);
   $tempLate = str_replace('{htmlNews}',htmlAbout($rs['z_a'],0,8,0,''),$tempLate);
   $tempLate = str_replace('{htmlHot}',htmlAbout($rs['z_a'],0,8,1,''),$tempLate);
   $tempLate = str_replace('{htmlSoure}',htmlTemplate(1),$tempLate);
   $tempLate = str_replace('php简单生成html静态页面代码',$rs['title'],$tempLate);
   $tempLate = str_replace('{htmlContent}',$rs['content'],$tempLate);
   $tempLate = str_replace('{description}',$rs['description'],$tempLate);
   $tempLate = str_replace('{keywords}',$rs['keywords'],$tempLate);
   makeHtml($tempLate,$filePath,$fileName);

function makeHtml($msgContent,$filePath,$fileName){//生成html文件  
  if(!is_dir($filePath)){@mkdir($filePath);} 
  //die($filePath);   
  $handle = fopen(str_replace('\','../',$filePath.$fileName),'w+') or die("can't create file!$fileName");
  fwrite($handle,$msgContent);
  fclose($handle);  
}

本站原创转截注明:www.226511.com/phper/php.html

补充:Php教程,Php入门 
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,