How does PHP generate static html?

Source: Internet
Author: User

Introduction: This is a detailed page for PHP to generate static html. It introduces PHP, related knowledge, skills, experience, and some PHP source code.

Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 324435 'rolling = 'no'>

Code:

// Add ob_start () to your start ();
Ob_start ();

// The following is your code
// The following is your code
.......

// Add ob_end_clean () to the end and output this page to a variable.
// Add ob_end_clean () to the end and output this page to a variable.
$ Temp = ob_get_contents ();
Ob_end_clean ();

// Write a file
// Write a file
$ Fp = fopen ('file name', 'w ');
Fwrite ($ FP, $ temp) or die ('file writing error ');
?>

Output Control Function explanation .......

Output Control Function
1. Flush: refresh the buffer content and output it.
Function Format: flush ()
Note: This function is frequently used and highly efficient.
2. ob_start: Open the output buffer.
Function Format: void ob_start (void)
Note: When the buffer zone is activated, all requests from PHPProgramThe non-file header information is not sent, but is saved in the internal buffer zone. To output the buffer content, you can use ob_end_flush () or flush () to output the buffer content.
3. ob_get_contents: returns the content of the internal buffer.
Usage: String ob_get_contents (void)
Note: This function returns the content in the Current Buffer. If the output buffer is not activated, false is returned.
4. ob_get_length: return the length of the internal buffer.
Usage: int ob_get_length (void)
Note: This function returns the length of the Current Buffer. It is the same as ob_get_contents if the output buffer is not activated. Returns false.
5. ob_end_flush: sends the content of the internal buffer to the browser and closes the output buffer.
Usage: void ob_end_flush (void)
Note: This function sends the content of the output buffer (if any ).
6. ob_end_clean: Delete the content of the internal buffer and disable the internal buffer.
Usage: void ob_end_clean (void)
Note: This function will not output the content of the internal buffer but delete it!
7. ob_implicit_flush: enable or disable absolute refresh
Usage: void ob_implicit_flush ([int flag])
Note: Anyone who has used Perl knows the meaning of $ | = x. This string can enable/disable the buffer, while the ob_implicit_flush function is the same as that. The buffer is disabled by default, after the absolute output is enabled, each Script output is directly sent to the browser, and you do not need to call flush ()

Read and Write files !! In addition:

$ URL _ = $ date. ". html ";
$ Tmpfname = tempnam ("/", "xnml ");
Copy ($ tmpfname, "html_files/". $ URL _);
Chmod ("../". $ URL _, 0755 );
Generally, only HTML is generated based on the publishing time of the content Title Author. If you want to display the number of readingsArticleAnd other dynamic information, which can be implemented by calling PHP using JS

More articles on "How PHP generates static html"

Love J2EE follow Java Michael Jackson video station JSON online tools

Http://biancheng.dnbcw.info/php/324435.html pageno: 14

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.