PHP output buffering cache and program Cache _php Tutorial

Source: Internet
Author: User
in < span=""> the < span=""> < span=""> < span=""> < span=""> < span=""> < span="">< span="">

If< span="">< span="">< span="">< span="">

Test below< span="">< span="">< span="">

In order to test the effect more clearly before the test, we< span="">< span="">< span="">< span="">

Output_buffering=off

Display_errors=on

Code< span="">< span="">

< span="">< span="">"PHP< span="">< span="">"(< span="">"content-type:text/html;charset="  < span="">    utf-8< span="">  '  ' OK< span="">  ';

It will appear

Php
Warning:cannot Modify header Information-headers already sent by (output started at d:\www\apache\htdocs\test\t2.php:2) In D:\www\apache\htdocs\test\t2.php on line 3
Ok

Code Listing 2:

< span="">< span="">< span="">< span="">< span="">"PHP< span="">< span="">"(< span="">"content-type:text/html;charset="  < span="">    utf-8< span="">  '  ' OK< span="">  ';

The result is completely correct.

Cause Analysis:

< span=""> code phpecho< span="">' php ' has sent a header message to the < span=""> browser,

When it comes back

Header ("content-type:text/html;charset= ' Utf-8 '");

Also saw a header message, this time has been called back to the above information, can not be more wrong.

< span=""> code ' < span=""> < span=""> < span=""> < span=""> PHP ' When the data to be called to the browser is first placed in< span="">< span="">< span="">< span="">< span="">< span="">

See the following code for a deeper understanding

Code< span="">< span="">

< span="">< span="">< span="">"PHP"< span="">< span="">("content-type:text/html;charset= ' Utf-8 '"  < span=""> )  < span="">  ' OK '  < span="">    < span="">
           
   '< span="">< span="">=< span="">< span="">< span=""> < span="">;

Will output

Ob_get_contents ()< span="">< span="">< span="">

Ob_get_contents ()< span="">< span="">< span="">

Code< span="">< span="">

< span="">< span="">< span="">< span="">< span="">"PHP< span="">< span="">"(< span="">);  < span="">  < span=""> ( " content-type:text/ < span="">  < span=""> html;charset=  < span="">    < span="">  '  utf-8< span="">  ' ' OK '  < span=""> < span="">< span=""> '
                    
   '< span="">< span="">< span="">=< span="">< span=""> < span="">< span="">< span="">;

Results:

Code< span="">< span="">

< span="">< span="">< span="">"PHP"< span="">< span="">();  < span="">  ( < span="">" content-type:text/html;charset= ' utf-8 '"  < span="">    ' OK< span="">  ' < span="">    < span=""> < span=""> 
              
   '< span="">< span="">=< span="">< span="">< span=""> < span="">;

Results:

Code< span="">< span="">

< span="">< span="">< span="">"PHP"< span="">< span="">();  < span="">  ( < span="">" content-type:text/html;charset= ' utf-8 '"  < span="">    ' OK< span="">  ' < span="">    < span=""> < span=""> 
              
   '< span="">< span="">=< span="">< span="">< span=""> < span="">;

Code< span="">< span="">< span="">< span="">< span="">< span="">

< span="">< span="">< span="">"PHP"< span="">< span="">();  < span="">  ( < span="">" content-type:text/html;charset= ' utf-8 '"  < span="">    ' OK< span="">  ' < span="">    < span=""> < span=""> 
              
   '< span="">< span="">=< span="">< span="">< span=""> < span="">;

Results:

Ob_clean ()

Empty< span="">< span="">

Ob_get_flush ()

Flush out cache to program cache, close< span="">< span="">

Code< span="">

< span="">< span="">< span="">' abc '< span="">< span="">("content-type:text/html;charset= ' Utf-8 '"  < span="">)   < span=""> ' Hello  ' < span="">  < span="">  < span="">  < span=""> ' AA '< span="">< span="">< span="">< span="">< span="">< span="">

2.ob_flush (), Flush ()< span="">

Code< span="">< span="">

< span="">< span="">< span="">' A '< span="">< span="">();< span="">< span="">< span="">< span="">< span="">< span="">< span="">

Code< span="">< span="">

< span="">< span="">< span="">' A '< span="">< span="">(); < span="">< span="">< span=""> "
Ob_con ".< span="">< span="">< span="">< span="">

< span="">

Code< span="">< span="">

< span="">< span="">("", 1024);  < span="">(=0  ;  < span=""> < span="">  < span="">  < span=""> <5; < span="">++< span="">< span="">< span="">< span=""> < span=""> "
< span="">"(< span="">1< span="">< span="">< span="">

Will output a number in a second.

If not< span="">< span="">

http://www.bkjia.com/PHPjc/440408.html www.bkjia.com true http://www.bkjia.com/PHPjc/440408.html techarticle in order to test the effect more clearly before testing in the following test, we output_buffering=off display_errors=on code "PHP" ("content-type:text/html;charset=" Utf-8 ' ' OK '; It will come out ...

  • 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.