PHP Learning Notes (eight)

Source: Internet
Author: User
Tags php write

About caching functions in PHP
Ob_start () and Ob_end_flush ().


PHP output mechanism: output---cache--output to the browser.
Ob_start (callback function) opens the output buffer, and all output information is no longer sent to the browser, but is processed at the callback function.
Ob_end_flush (); Output all the contents of the buffer and close the buffer.


The effect of OB output buffering:
1. Prevent errors caused by using Setcookie, header, session_start () function improperly (after output).
2. Capture some non-accessible output, such as the output of phpinfo (), the server can use the OB function to obtain the server information saved as a file without output, so that can be friendly or covert access to the server information.
3. Process the content of the output, such as faster transfer: After capturing the content, compress the content using gzip, and then use unzip at the receiving point, which speeds up the file transfer. or the content of other processing, such as Chinese and English processing, encoding processing.
4. Generate static file, static template technology: Can let the output of PHP write to an HTML file, if there is no dynamic access, directly let the user see that static page, if there is input access, then call PHP file, re-write HTML page, This has a great effect on the performance improvement of a website with large traffic.


Description of the correlation function:
Ob_start () Open buffer
Ob_flush () Refreshes the contents of the buffer, the output
Ob_get_contents () returns the contents of the buffer
Ob_get_length () returns the length of the buffer
Ob_end_flush () sends buffer contents to the browser and closes the buffer
Ob_end_clean () Delete buffer contents (not output), and close buffer
Ob_implicit_flush () turns absolute refresh on or off. When an absolute refresh is turned on, each script output is sent directly to the browser without the need to call the flush () function again.

PHP Learning Notes (eight)

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.