function | control PHP4 new FUNCTION Introduction-Output information control function
Demon Clan Elf
These functions allow you to control the content of your script output. Can be used in a number of 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 the header information that is sent using header () or Setcookie (), but only those similar to Echo () and PHP code data blocks are useful.
Example 1. Control output
<?php
Ob_start ();
echo "hello\n";
Setcookie ("CookieName", "Cookiedata");
Ob_end_flush ();
?>
In the above example, 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.)
The correlation function header () and Setcookie ().
Korean Series table
flush-Flush Output Buffer
Content saved in the output buffer is sent to the browser
ob_start-Open Output Buffer
So all the 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 the 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-End (send) output buffer content, turn off output buffer
ob_end_clean-Deletes (discards) the contents of the output buffer and closes the output buffer
If your program finds that there is a problem with the output, you can discard all output and prevent some secret information from leaking
ob_implicit_flush-turn on or off direct refresh
Once opened, each script output is sent directly to the browser and no longer needs to invoke flush ().
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.