PhpCannotmodifyheaderinformation-headersalreadysent_PHP tutorial

Source: Internet
Author: User
PhpCannotmodifyheaderinformation-headersalreadysent. This article introduces a variety of solutions for phpCannotmodifyheaderinformation-headersalreadysentbyset. if you need it, refer to it. In the php configuration file php. ini, This article introduces a variety of solutions for the php Cannot modify header information-headers already sent by set. if you need it, refer to it.

Set output_buffering to On in the php configuration file php. ini. Enable.

Output_buffering = On

-------------------------------
All or nothing, now or never.


There are several solutions:

1. Blank lines (Blank line ):
Make sure no blank line after Of the calling php script.
Check whether There are no blank lines, especially include or require files. Many problems are caused by these blank rows.

2. Use exit statement (Use exit to solve ):

The code is as follows:
Use exit after header statement seems to help some people
Add exit () after the header ();
Header ("Location: xxx ");
Exit ();

Use Javascript ):

The code is as follows:

Since it's a script, it won't modify the header until execution of Javascript.
You can use Javascript to replace the header. However, the above code is not successfully executed... you need to note that using this method requires the browser to support Javascript.

3b. Use output buffering (solved by the output cache ):

The code is as follows:

... HTML codes...
... PHP codes...
Header ("Location :....");
Ob_end_flush ();
?>

Could Cannot modify header information-headers already sent by set Solution. if you need it, please refer to it. In the php configuration file php. ini...

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.