Cannot modify header information problem solving method (PHP), modifyheader_php tutorial

Source: Internet
Author: User

Cannot modify header information problem solving method (PHP), Modifyheader


I made a unified error prompt function, in the function execution, first processing the error address to write a cookie to facilitate the user login can jump directly to the page to be executed, but found on the server test, unexpectedly prompted the local did not appear error: Warning:cannot Modify header Information-headers already sent by ....
Such statements, it is obvious that the cause of this is caused by Setcookie, looked at the Internet, like the following explanation: The cookie itself has some restrictions on the use of, for example:
1. The statement of the call Setcookie must be placed inLabel before
2. Do not use the echo before calling Setcookie
3. Cookies will not appear in the program until the Web is re-loaded
The 4.setcookie function must be sent out before any information is delivered to the browser.
5 .....
Based on these limitations, when you execute the Setcookie () function, you often encounter "Undefined index", "Cannot modify header Information-headers already sent by" ... And so on, the "cannot modify header Information-headers already sent by" is the wrong way to delay the information output to the browser before the cookie is generated, so you can add ob_ to the front of the program. Start (); this function. This will solve the problem. If you want to add Ob_start (), it is not feasible, the program is finished, just to change this seems a little depressed. When I found out this error, I was wondering how I did not prompt the problem locally, and thought it was php.ini configuration is not the same, think and wrong, are almost the same.
So look at the following phrase "output started at ..." means that the output is already in the other place before the Setcookie, so find the file that the output started at followed, see the first line is blank, and then the The solution is complete!
Workaround Two:
Finding ways to solve this problem on the Internet is much the same, but today it is a problem. After the test, it is possible to find:
Find php.ini This configuration file, and then look for an entry: output_buffering change its value from the original off to ON, restart Apache OK.

PS: Sometimes, when you re-build your PHP application, this can happen if your jump and Setcookie are not supported. Need to follow SAE development documentation specifications.

http://www.bkjia.com/PHPjc/962050.html www.bkjia.com true http://www.bkjia.com/PHPjc/962050.html techarticle cannot modify header information Problem Resolution (PHP), Modifyheader I made a unified error prompt function, in the function execution, first processing the wrong address to write a cookie to ...

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