The solution of PHP using header jump failure

Source: Internet
Author: User
The example of this article describes the PHP use header jump failure solution, share for everyone for reference. The specific methods are analyzed as follows:

First, the question:

Today header (\ "Location: $url \"), the past jump always can, but today does not move, just the output, the past to confirm the check, $url the value is correct, so in the front with the Echo $url; The result is an invalid header function.

Second, the solution:

In PHP with the header ("location:test.php") to jump to pay attention to the following points:

1, location and ":" No space between, otherwise it will be wrong.//phpfensi.com

2, before using the header can not have any output, including the page of the include label "?>" cannot have a space.

3. The PHP code after the header will also be executed.

The header of PHP cannot have any content output before it jumps because PHP has sent the HTTP header information to the browser when it starts executing, and then it is no longer allowed to change.

However, if you have to process header information after the output, you can use Ob_start () Ob_end_flush () to cache the content you want to send, and wait until the header continues to send the content.

Or an easier way to modify php.ini, to find Output_buffering=off modified to output_buffering=4096.

I hope this article is helpful to everyone's PHP programming.



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.