PHP: Summary of output buffer processing function usage

伊谢尔伦
Release: 2023-03-11 10:10:01
Original
1420 people have browsed it

The function of the output buffer processing function is somewhat similar to the C stack, which is temporarily placed in a storage space to process the content.

The output buffer functions are:

The example is as follows:

<?php  
 define(&#39;APP_ROOT&#39;, dirname(FILE));
 $file = &#39;/templates/html/error_config.html&#39;;
 ob_start(); 
 include(APP_ROOT.$file);
 ob_end_flush();
   //$contents = ob_get_contents();  这样可以将输出保存,可以作进一步处理
  //ob_end_clean();
   //echo $contents;
 ?>
Copy after login
<?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; charset=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>
Copy after login

The output result is as follows:

config.php does not exist or is not readable by the webserver in the phpsysinfo directory.
Copy after login

The above is the detailed content of PHP: Summary of output buffer processing function usage. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template