PHP solution to invalid header jump_PHP tutorial

WBOY
Release: 2016-07-13 10:14:03
Original
803 people have browsed it

Solution to PHP header jump failure

1. Problem:

Today’s header("Location: $url"), in the past it was always possible to jump, but today it does not move, it just outputs the result. In the past, I had to confirm and check whether the value of $url was obtained correctly, so add it in front Echo $url; is used for debugging, which results in the header function being invalid.

2. Solution:

When using header("location:test.php") to jump in PHP, please pay attention to the following points:

1. There cannot be a space between location and ":", otherwise an error will occur.//downcc.com

2. There cannot be any output before using the header, including the include page. There must be no space after the tag "?>".

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

No content can be output before PHP's header jumps, because PHP has already sent the HTTP header information to the browser when it starts executing, and changes are no longer allowed after that.

But if you have to process the header information after output, you can use ob_start() ob_end_flush() to cache the content to be sent, and wait until the header continues before sending the content.

Or a simpler way, modify php.ini, find output_buffering=Off and change it to output_buffering=4096.

I hope this article will be helpful to everyone’s PHP programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/911718.htmlTechArticlePHP uses header jump failure solution 1. Problem: Today’s header (Location: $url), jump in the past It is always possible to transfer, but today it doesn’t work. It just outputs the results. In the past, I had to confirm and check...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template