Notes on using PHP Header for page jumps: 1. There cannot be a space between location and [:], otherwise an error will occur; 2. There cannot be any output before using the header; 3. After the header The PHP code will also be executed.
Notes on PHP Header used for page jumps:
The following is the redirection in asp## Comparison of #response.redirect:
Example 1:
response.redirect "../test.asp" header("location:../test.php");
redirectThe function can work after sending the header file to the client.
<html><head></head><body> <%response.redirect "../test.asp"%> </body></html>
<html><head></head><body> <? header("location:../test.php"); ?> </body></html>
<? header("location:../test.php"); ?> <html><head></head><body>...</body></html>
Example 2:<html><head></head><body>
<%
response.redirect "../a.asp"
response.redirect "../b.asp"
%>
</body></html>
a.aspWhere is the file.
<? header("location:../a.php"); header("location:../b.php"); ?> <html><head></head><body></body></html>
b.php.
if(...) header("..."); else { ... }
if(...) { header("...");exit();}
<[email=%@]%@LANGUAGE="VBSCRIPT[/email]" CODEPAGE="936"%> <%if Request.ServerVariables("SERVER_NAME")="s.jb51.net" then response.redirect "news/index.htm" else%> <%end if%> <script> var url = location.href; if(url.indexOf('http://www.devdao.com/')!=-1)location.href='/index/index.htm'; if(url.indexOf('http://www.knowsky.com/')!=-1)location.href='/index1/index.htm'; if(url.indexOf('http://www.google.com/')!=-1)location.href='/cn/index.asp'; if(url.indexOf('http://www.baidu.com/')!=-1)location.href='/cn/index.asp'; </script>
Related learning recommendations:php programming(video)
The above is the detailed content of What are the precautions for using PHP Header to jump to pages?. For more information, please follow other related articles on the PHP Chinese website!