PHP static file generation class instance ,. PHP static file generation class instance. This article describes the PHP static file generation class. Share it with you for your reference. The specific implementation code is as follows: Copy the code as follows: phpclass PHP static file generation class instance,
This example describes the PHP static file generation class. Share it with you for your reference.
The specific implementation code is as follows:
The 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 'this directory does not exist'. $ path;
Mkdir ($ path, 0755 );
}
}
Return $ filePath. $ p;
}
Function start ()
{
Ob_start ();
}
Function end ()
{
$ Info = ob_get_contents ();
$ FileId = '000000 ';
$ 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 usage is as follows:
The code is as follows:
<? Php
$ S = new CreateHtml ();
$ S-> start ();
?>
Asdfasdfasdfasdfasdfasdfasdfasdfasdfasdf
Adfasdfasdf
>
<? Php
$ S-> end ();
?>
I hope this article will help you with PHP programming.
Example: PHP static file generation class. Share it with you for your reference. The specific implementation code is as follows: php class...