PHP static file generation class instance,
The example in this paper describes the PHP static file generation class. Share to everyone for your reference.
The specific implementation code is as follows:
Copy CodeThe code is as follows: <?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 ' does not have this 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 CodeThe code is as follows: <?php
$s =new createhtml ();
$s->start ();
?>
Asdfasdfasdfasdfasdfasdfasdfasdfasdf
Adfasdfasdf
>
<?php
$s->end ();
?>
I hope this article is helpful to everyone's PHP programming.
http://www.bkjia.com/PHPjc/919616.html www.bkjia.com true http://www.bkjia.com/PHPjc/919616.html techarticle php static file generation class instance, this article describes the PHP static file generation class. Share to everyone for your reference. The implementation code is as follows: Copy code code as follows: PHP class ...