The function of the output buffer processing function is similar to the C stack. It is temporarily put into a bucket to process the content.
The output buffer functions include:
- Ob_start ()-Enable Output Control Buffer
- Ob_get_length ()-return the length of the output buffer.
- Ob_get_level ()-return the nested level of the output buffer
- Ob_get_status ()-return the status of the output buffer (returned in array format. The top-level is returned by default. If the parameter is true, all values are returned)
- Ob_get_contents ()-return the content of the output buffer
- Ob_get_clean ()-returns the current output buffer in string format and closes the output buffer
- Ob_end_clean ()-clear (erase) the buffer and disable the output buffer.
- Ob_get_flush ()-return the output buffer content with a string and disable the buffer
- Ob_end_flush ()-washed out (sent) output buffer content Buffer
Example:
<? PHP Define ('App _ root ', Dirname ( _ File __ )); $ File = '/Templates/html/error_config.html' ; Ob_start (); Include (App_root. $ File ); Ob_end_flush (); // $ Contents = ob_get_contents (); this saves the output and can be further processed. // Ob_end_clean (); // Echo $ contents; ?>
<?PHP echo "<? XML version = \ "1.0 \" encoding = \ "UTF-8 \"> ";?> <! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" > < Html Xmlns = "Http://www.w3.org/1999/xhtml" > < Head > < Meta HTTP-equiv = "Content-Type" Content = "Text/html; charsets = UTF-8" /> < Meta HTTP-equiv = "Content-script-type" Content = "Text/JavaScript" /> < Meta HTTP-equiv = "Content-style-type" Content = "Text/CSS" /> < Title > Error </ Title > </ Head > < Body Onload = "Doredirect ()" > < H1 > Error </ H1 > < Div Style = "Position: absolute; top: 150px; text-align: center; width: 95% ;" > < P Style = "Margin: 12pt ;" > < Strong > Config. php </ Strong > Does not exist or is not readable by the webserver in the directory.</ P > < P Style = "Margin: 12pt ;" > <?PHP echo commonfunctions: $ psi_version_string?> </ P > </ Div > </ Body > </ Html >
The output result is as follows:
Config. php does not exist or is not readable by the webserver in the phpsysinfo directory.