Introduction to new functions of PHP4-Output information control function

Source: Internet
Author: User
Tags flush functions header php code setcookie
Functions | Control These functions allows you to control the content of your script output. It can be used in many different situations, especially if your script has already output information and needs to send a new file header. The output control function does not affect file header information sent using header () or Setcookie (), only for blocks of data similar to echo () and PHP code.





Example 1. Control output





<?php





Ob_start ();


echo "Hellon";





Setcookie ("CookieName", "Cookiedata");





Ob_end_flush ();





?>





in the example above, the output with Echo () is saved in the output buffer until the Ob_end_flush () is invoked. What makes sense is that the contents of the call Setcookie () are stored successfully in the cookie without causing an error. (Normally, you cannot send file header information to the user's browser after the data has been sent.)





Correlation function Header () and Setcookie ().





Korean Series Table


flush-Flush Output Buffer

The contents of the
saved in the output buffer are sent to the browser





ob_start-Open Output Buffer


so that all output information is not sent directly to the browser, but is stored in the output buffer





ob_get_contents-Returns the contents of the output buffer


if you want to process output later, you can call this function to keep a backup





ob_get_length-returns the content length of the output buffer





ob_end_flush-the contents of the end (send) output buffer, turn off the output buffer





ob_end_clean-Delete (discard) The contents of the output buffer and turn off the output buffer


If your program finds that there is a problem with the output, you can discard all the output and prevent some secret information from leaking





ob_implicit_flush-turn on or off direct refresh

Once
is open, each script output is sent directly to the browser and no longer requires a call to flush ()





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.