欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

PHP靜態(tài)文件生成類實(shí)例

 更新時間:2014年11月29日 15:07:43   投稿:shichen2014  
這篇文章主要介紹了PHP靜態(tài)文件生成類,以實(shí)例形式演示了PHP生成靜態(tài)文件的方法,并封裝成類文件便于使用,是非常實(shí)用的技巧,需要的朋友可以參考下

本文實(shí)例講述了PHP靜態(tài)文件生成類。分享給大家供大家參考。

具體實(shí)現(xiàn)代碼如下:

復(fù)制代碼 代碼如下:
<?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()
{
$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();
}
}
?>

具體用法如下:
復(fù)制代碼 代碼如下:
<?php
$s=new CreateHtml();
$s->start();
?>
<html>
<body>
asdfasdfasdfasdfasdfasdfasdfasdfasdf<br>
adfasdfasdf<br>
</body>>
</html>
<?php
$s->end();
?>

希望本文所述對大家的PHP程序設(shè)計有所幫助。

相關(guān)文章

最新評論