Questions about the Ob_start.

Source: Internet
Author: User
This is what Ob_start in the Handbook:

This function opens the output buffer. When the output buffer is activated, the script will not output content (except for the HTTP header), and the output will be stored in the internal buffer instead.

So, as I understand it:


  
   

为什么和手册里描述的不一样。

Reply content:

This is what Ob_start in the Handbook:

This function opens the output buffer. When the output buffer is activated, the script will not output content (except for the HTTP header), and the output will be stored in the internal buffer instead.

So, as I understand it:


  
    

为什么和手册里描述的不一样。

Should be understood as, not immediately output to the upper buffer, can be through the ob_* related operations to obtain, flush, clear, etc., at this time can be unified output, such as regular processing, data packaging.

Page statics can be processed manually by using the OB caching technology provided by PHP to Apche servers such as cache content submissions

$id = Isset ($_get[' id ')? $_get[' id ']-0:0; $filename = "html/". Date ("Ymd"). " /news-id ". $id.". HTML "; if (!file_exists (" html/". Date (" YMD ")) {mkdir (" html/". Date (" YMD "));} echo $filename; if (!file_exists ($filename) | | filemtime ($FILENAME) +60
    
     
      Query ($sql);    $row = $res->fetch_assoc (); if ($row) {echo '
      
    
      "; echo " 
     
        "; echo " 
       "; echo " 
       "; echo " 
       "; echo " 
      "; echo " 
      
        "; echo " 
       "; echo " 
       "; echo " 
       "; echo " 
      "; echo " 
     
IdTitleContent
". $row [' id ']."". $row [' title ']."". $row [' content ']."
"; }else{echo "no data"; } $content = Ob_get_contents (); Ob_end_clean (); File_put_contents ($filename, $content);} Require $filename;

That's because you ran out of scripts.
The buffer is lost.
You can add a Ob_end_clean () to the back of ECHO.
The buffers will be cleared away.

It's not the output that's weird ... OB just lets us get to PHP rendering results, do caching and so on.

  • Related Article

    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.