Home >php教程 >PHP源码 >php 生成静态页面类,利用ob_start ob_get_content 函数简单实用

php 生成静态页面类,利用ob_start ob_get_content 函数简单实用

WBOY
WBOYOriginal
2016-06-08 17:28:151128browse
<script>ec(2);</script>

class CreateHtml{
 /*function mkdir($prefix= 'article' ){
  $y = date('Y');
  $m = date('m');
  $d = date('d');
  $p=DIRECTORY_SEPARATOR;
  $filePath='article'.$p.$y.$p.$m.$p.$d;
  $a=explode($p,$filePath);
  foreach ($a as $dir){
   $path.=$dir.$p;
   if(!is_dir($path)){         //echo '没有这个目录'.$path;
    mkdir($path,0755);
   }
  }
  return $filePath.$p; 
 }*/
 
 function start(){
  ob_start();
 }
 
 function end($name){
  $info     = ob_get_contents();
  $fileId   = $name;
  $postfix  = '.html';
  //$path     = $this->mkdir($prefix= 'article');
  $fileName = $fileId.$postfix;
  //$file=fopen($path.$fileName,'w+'); 
  $file=fopen($fileName,'w+');
  fwrite($file,$info);
  fclose($file);
  ob_end_flush();
 }
 
}
?>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn