Comparison between PHP header and ASP redirect

Source: Internet
Author: User

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 ;}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.