PHP uses the solution to invalid header jump, phpheader jump fails_PHP tutorial

WBOY
Release: 2016-07-13 10:16:01
Original
1164 people have browsed it

Solution to PHP header jump failure, phpheader jump failure

The example in this article describes the solution to the failure of header jump using PHP, and is shared with everyone for your reference. The specific method analysis is as follows:

1. Question:

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.//phpfensi.com

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

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.

php header() page jump problem

If you are sure to use the post method to submit, it is a very complicated matter, because PHP is needed to simulate post submission. You can use fsockopen to handle it. I can teach you the specific solution.
Another method is to use the get solution. Relatively speaking, it is super simple. When direct redirection, just convert the data from the post into the get header.
Another solution is to use ajax in the front end. Ajax submits data to b.php on page a. If the return value indicates that the verification is not passed, then the page is transferred to b.php using js. If the return value indicates that the verification is passed, the data of the current post is submitted to c again. .php.

The php header cannot be jumped. There is no problem on the local machine, but there is a problem when uploading to the server. The jump cannot be made. You have to refresh to jump to the specified page

Encoding problem. Change charset=UTF-8 to charset=GB2312

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/899065.htmlTechArticleSolution to PHP using header jump failure, phpheader jump failure This article tells the example of PHP using header jump failure The solution is shared with everyone for your reference. Specific method analysis...
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