The solution of PHP using header jump invalidation

Source: Internet
Author: User

First, the question:

Today header ("Location: $url"), the previous jump can always be, today is not moving, just output results, the past to confirm the check, $url the value of the correct, so in front of the echo $url; The result is an invalid header function.

Second, the solution:

In PHP, use header ("location:test.php") to jump to note the following points:

1, location and ":" No space between the number, or there will be errors.//downcc.com

2, before using header can not have any output, including included in the page labeled "?>" can not have spaces.

3, after the header of the PHP code will also be executed.

PHP header jump can not have any content output before, because PHP began to execute the browser has sent HTTP header information, and then no longer allow changes.

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, until the header continues to send the content.

Or a simpler way to modify php.ini, find Output_buffering=off modified to output_buffering=4096.

I hope this article will help you with your PHP program design.

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.