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.