The response. Redirect function is used to implement redirection in ASP:
Example:
Response. Redirect ".../test. asp"
PHP also has similar functions: Header
Example:
Header ("Location: ../test. php ");
However, the two are different.
The Redirect function of ASP can work after the header file is sent to the customer.
For example
<HTML> <% Response. Redirect ".../test. asp" %>
</Body> Check the example below in PHP Code An error is reported:
<HTML> <?
Header ("Location: ../test. php ");
?>
</Body> You can only do this:
<?
Header ("Location: ../test. php ");
?>
<HTML> That is, the header function cannot send any data to the customer.
let's look at the following example:
Asp
<%
response. redirect ".. /. ASP "
response. redirect ".. /B. ASP "
%>
the result is redirection. ASP file.
what about PhP?
header ("Location: ../a. php");
header ("Location: ../B. php");
?>
redirect B. PHP.
no subsequent code is executed after redirect is executed in ASP.
PHP continues to execute the following code after executing the header.
in this regard, PHP's header redirection is not as good as ASP's redirection. sometimes we cannot execute the following code after redirecting:
generally we use
If (...)
header ("... ");
else
{< br>...
}< br> but we can simply use the following method:
If (...)
{header ("... "); break ;}