This article mainly introduces how PHP uses the header to jump to an invalid solution, and summarizes the precautions for such problems, which is of great practical value, for more information about how PHP uses the header to redirect to invalid content, see the example in this article. The specific method is analyzed as follows:
I. problems:
Today's header (\ "Location: $ url \"), the previous jump is always possible, but today it does not move, only the output results, in the past you have to confirm the check, the $ url value is obtained correctly. Therefore, echo $ url is added in front of the url for debugging. as a result, the header function is invalid.
II. solution:
When using header ("location: test. PHP") in php to redirect, pay attention to the following points:
1. no space is allowed between location and:; otherwise, an error occurs. // phpfensi.com
2. there cannot be any output before using the header, including the "?>" tag on the include page" There cannot be spaces.
3. the PHP code after the header is executed.
No content can be output before the PHP header jump, because the HTTP header information has been sent to the browser at the beginning of PHP execution and cannot be changed.
However, if you have to process the header information after the output, you can use ob_start () ob_end_flush () to cache the content to be sent and wait until the header continues to send the content.
Or a simpler method is to modify php. ini and find output_buffering = Off and change it to output_buffering = 4096.
I hope this article will help you with PHP programming.