Home > Backend Development > PHP Tutorial > PHP static file generation class instance, _PHP tutorial

PHP static file generation class instance, _PHP tutorial

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-07-13 10:12:48
Original
917 people have browsed it

PHP static file generation class instance,

The example in this article describes the PHP static file generation class. Share it with everyone for your reference.

The specific implementation code is as follows:

Copy code The code is as follows:
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 'No such directory'.$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();
}
}
?>

The specific usage is as follows:
Copy code The code is as follows:
$s=new CreateHtml();
$s->start();
?>


asdfasdfasdfasdfasdfasdfasdfasdfasdf

adfasdfasdf

>

$s->end();
?>

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/919616.htmlTechArticlePHP static file generation class example, this article describes the PHP static file generation class example. Share it with everyone for your reference. The specific implementation code is as follows: Copy the code The code is as follows: php class...
Related labels:
source:php.cn
Statement of this Website
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template