Home  >  Article  >  Backend Development  >  PHP static file generation class_PHP tutorial

PHP static file generation class_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:58:50746browse

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...
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