PHP static file Generation class instance, _php tutorial

Source: Internet
Author: User
Tags php programming

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

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.