PHP Header and ASP redirect Comparison _php tutorial

Source: Internet
Author: User
To implement redirection in ASP is to use the Response.Redirect function:
To use one example:
Response.Redirect ". /test.asp "
There are similar functions in PHP: Header
To use one example:
Header ("Location:.. /test.php ");
But there is a difference between the two.
The redirect function of an ASP can work after sending a header file to the customer.
Such as

<%response.redirect ". /test.asp "%>

Check that the following code in PHP will report an error:

Header ("Location:.. /test.php ");
?>

This is the only way:
Header ("Location:.. /test.php ");
?>
...
That is, the header function cannot send any data to the customer before.

Look again at the following example:
in ASP

<%
Response.Redirect ". /a.asp "
Response.Redirect ". /b.asp "
%>

The result is a redirected a.asp file.
What about PHP?
Header ("Location:.. /a.php ");
Header ("Location:.. /b.php ");
?>

We found it redirected b.php.
The subsequent code is no longer executed after executing redirect in ASP.
PHP continues to execute the following code after the header is executed.
In this regard, header redirection in PHP is not as good as redirection in ASP. Sometimes after we redirect, we cannot execute the following code:
Generally, we use
if (...)
Header ("...");
Else
{
...
}
But we can simply use the following method:
if (...)
{Header ("..."); break;}

http://www.bkjia.com/PHPjc/315442.html www.bkjia.com true http://www.bkjia.com/PHPjc/315442.html techarticle To implement redirection in ASP is to use Response.Redirect function: Use one example: Response.Redirect. /test.asp PHP also has similar functions: Header usage Example: Header (location:. /test.php); But both ...

  • 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.