Home > Backend Development > PHP Problem > What should I do if php uses header jump to be invalid?

What should I do if php uses header jump to be invalid?

王林
Release: 2023-03-13 11:24:02
Original
5236 people have browsed it

Solution to invalid php header jump: 1. Find and open the php.ini configuration file; 2. Change output_buffering = Off to output_buffering = 4096; 3. Restart the server.

What should I do if php uses header jump to be invalid?

The operating environment of this article: windows10 system, php 7, thinkpad t480 computer.

Solution:

1. Modify php.ini;

2. Find output_buffering=Off and modify it to output_buffering=4096;

3. Restart the server.

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

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

3. Header The subsequent PHP code will also be executed.

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

But if you must 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.

Recommended learning: php training

The above is the detailed content of What should I do if php uses header jump to be invalid?. For more information, please follow other related articles on the PHP Chinese website!

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