Phpoutputbuffering cache and program cache _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
Phpoutputbuffering cache and program cache. If the following test is performed before the test to make the test more effective, we will output the following code in Output_bufferingoffDisplay_errorson php (content-type: texthtml; charsetutf-8ok; In

If

Test

Before the test, to make the test more effective, we

Output_buffering = off

Display_errors = on

Code

  "php" ("content-type:text/html;charset='utf-8'"  'ok';

The

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 2:

   "php" ("content-type:text/html;charset='utf-8'"  'ok';

The results are completely correct.

Cause analysis:

The code Phpecho 'php' already sends a header to the browser,

When

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

The header information is displayed again, and the above header information has been recalled. this error cannot be solved.

Put the data to be sent to the browser in the 'php' code first

Let's look at the following code for better understanding:

Code

 "php"("content-type:text/html;charset='utf-8'" 'ok' '
  '= ;

Output

Ob_get_contents ()

Ob_get_contents ()

Code

   "php" (); ("content-type:text/html;charset='utf-8'"  'ok'  '
  ' =  ;

Result:

Code

 "php"();("content-type:text/html;charset='utf-8'" 'ok' '
  '= ;

Result:

Code

 "php"();("content-type:text/html;charset='utf-8'" 'ok' '
  '= ;

Code

 "php"();("content-type:text/html;charset='utf-8'" 'ok' '
  '= ;

Result:

Ob_clean ()

Clear

Ob_get_flush ()

Clears the cache to the program cache and closes it.

Code

 'abc'("content-type:text/html;charset='utf-8'" 'hello' 'aa' 

2. ob_flush (), flush ()

Code

 'a'(); 

Code

 'a'(); "
ob_con".

Code

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

A number is output in one second.

If no

Else if the following test is performed before the test to make the test more effective, we will go to Output_buffering = off Display_errors = on code "php" ("content-type: text/html; charset = 'utf-8' "'OK'; then...

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.