Response is used to implement redirection in asp. redirect function: Usage example: response. redirect ".. /test. asp "php also has similar functions: header Usage example: header (" location :.. /test. php "), but the two are different. the redirect function of asp can be
AspUsing the response. redirect function:
Example:
Response. redirect '../test. asp'
PhpThere are also similar functions: header
Example:
Header ('Location: ../test. php ');
However, there is a difference between the two.
AspThe redirect function can work after the header file is sent to the customer.
For example
<% Response. redirect '../test. asp' %>
Check yesPhpThe following code reports an error:
Header ('Location: ../test. php ');
?>
You can only do this:
Header ('Location: ../test. php ');
?>
...
That is, the header function cannot send any data to the customer.
Let's look at the following example:
AspMedium
<%
Response. redirect '.../a. asp'
Response. redirect '../B. asp'
%>
The result is to redirect the. asp file.
PhpWhat about it?
Header ('Location: ../a. php ');
Header ('Location: ../B. php ');
?>
We invented it to redirect B. php.
After performing redirect in asp, the subsequent code will not be executed.
Php continues to execute the following code after fulfilling the header.
In this regard, the header redirection in php is not as good as the redirection in asp. sometimes, after we want to redirect, we cannot perform the following code:
Generally, we use
If (...)
Header ('...');
Else
{
...
}
However, we can simply use the following method:
If (...)
{Header ('...'); break ;}