Home >Backend Development >PHP Problem >What should I do if php uses header jump to be invalid?
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.
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!