Php functions: ob_start (), ob_end_clean (), and ob_get_contents (). This article introduces php functions ob_start (), ob_end_clean (), and ob_get_contents (). If you need them, refer to them. The usage of the following three functions:
This article introduces php functions ob_start (), ob_end_clean (), and ob_get_contents (). If you need them, refer to them.
Usage of the following three functions
Ob_get_contents ()-return the content of the output buffer
Ob_get_contents
(PHP 4,
For ($ I = 10; $ I> 0; $ I --){Echo $ I;Flush ();Sleep (1 );}?>According to the php ManualThis function sends all the output of the program so far to the user's browser.The above code should output $ I every second. But not necessarily in reality.
Ec (2); let's look at a piece of code first. & Lt ;? Phpfor ($ i10; $ I & gt; 0; $ I --) {& nbsp; echo $ I; & nbsp; flush (); & nbsp; sleep (1 );}? & Gt; according to the statement in the php manual & nbsp; this function sends all the output of the
For ($ I = 10; $ I> 0; $ I --){Echo $ I;Flush ();Sleep (1 );}?>
According to the PHP Manual
This function sends all the output of the program so far to the user's browser.
The above code should output $ I every second. But not necessarily in
Let's look at a piece of code first:
〈?php
for ($i =10; $i 〉0; $i--)
{
echo $i;
Flush ();
Sleep (1);
}
?〉
According to the PHP manual, the function sends all the output of the program so far to the user's browser.
The above code should output $i
The output cache of PHP can be nested. You can output nesting levels with Ob_get_level ().The test found that the output was different between the CLI and the browser (PHP5.4).
The manual describes the following:
Ob_get_level () would always
Buffer control in PHP. PHP4.0 provides a set of output buffer functions. The output buffer allows you to write the function to compress the buffer. The output buffer in PHP4 supports storing HTML header information, regardless of whether PHP4.0
Let's take a look at the Code:For ($ I = 10; $ I> 0; $ I --){Echo $ I;Flush ();Sleep (1 );}? > 〉According to the php manual, this function sends all the output of the program so far to the user's browser.The above code should output $ I every second.
For ($ I = 10; $ I> 0; $ I --){Echo $ I;Flush ();Sleep (1 );}?>According to the PHP ManualThis function will be available until now Program All the output is sent to the user's browser.The above section Code , $ I should be output every second. But
What is a buffer?Simply put, the function of the buffer is to put the input or output of the content into the memory, and not display or read. As to why there is a buffer, this is a very broad problem, if interested, you can find the information in
What is a buffer?Simply put, the function of the buffer is to put the input or output of the content into the memory, and not display or read. As to why there is a buffer, this is a very broad problem, if interested, you can find the information in
By default, the output of a string to the browser, after 3 stages of PHP buffer->tcp buffer-> Browser (some versions of IE browser also exist buffer)PHP default is to open the output buffer, in php.ini can be configured output_buffering=4096 (4KB, a
When PHP scripts have output, the output control function can use these to control the output. This is useful in many different situations, especially when the script starts to output data, it sends the http header information to the browser. The
In actual use
For example, the following PHP error warning cannot modify the header information:
Warning: Cannot modify header information-headers already sent
We may have encountered this problem when we were writing PHP programs. Literally, it
PHP4.0 provides a set of output buffer functions. The output buffer allows you to write the function to compress the buffer. The output buffer in PHP4 supports storing HTML header information, regardless of whether the HTML body is output or not.
These functions allow you to control the content output by your script. it can be used in many different situations, especially when your script has output information, you need to send a new file header. the output control function does not affect
How to solve the problem that PHP cannot modify the header information. In actual use, for example, the following PHP error message cannot be modified: Warning: Cannotmodifyheaderinformation-headersalreadysentby we have just started to write PHP
With regard to Citrix's ICA protocol, his full English name, which is called Independent computingarchitecture, is translated into Chinese as an independent computing architecture. But according to Citrix's internal material, it can also be referred
About ob_start (); would you like to ask: ob_start (); ob_get_contents (); ob_end_clean (); what are the specific functions and when they are used, review the new function introduction of PHP4 in the response from the November 03-output information
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.