php 生成静态页面类,利用ob_start ob_get_content 函数简单实用
<?php 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(); } }
永久链接:http://www.phprm.com/code/c3dbb4d1051f61b18beed89e35e5ec7a.html
转载随意!带上文章地址吧。