首頁  >  文章  >  後端開發  >  PHP静态文件生成类_PHP教程

PHP静态文件生成类_PHP教程

WBOY
WBOY原創
2016-07-13 10:58:50800瀏覽

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()
{
$info = ob_get_contents();
$fileId = '12345';
$postfix = '.html';
$path = $this->mkdir($prefix= 'article');
$fileName = time().'_'.$fileId.$postfix;
$file=fopen($path.$fileName,'w ');
fwrite($file,$info);
fclose($file);
ob_end_flush();
}
}
?>
$s=new CreateHtml();
$s->start();
?>


asdfasdfasdfasdfasdfasdfasdfasdfasdf

adfasdfasdf

>

$s->end();
?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/631968.htmlTechArticle?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=exp...
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn