The difference between PHP and ASP about the steering function

Source: Internet
Author: User
Tags header php and

Implementing redirection in

ASP is using the response.redirect function:

  usage:
  Response.Redirect ". There are similar functions in/test.asp

php : header

  usages:
  Header ("Location:.") /test.php ");
But there is a difference between the two. The redirect function of

ASP can work after a header file is sent to the customer.

 , such as
<%response.redirect. /test.asp "%>
</body>
Check is PHP The next example code will report an error:

.
Header ("Location:.. /test.php ");
?>
</body>
can only do so:


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

That is, the header function cannot send any data to the customer.

Look at one of the following examples:

In ASP

<%
Response.Redirect ". /a.asp "
Response.Redirect ". /b.asp "
%>
</body>
The result is a redirected a.asp file.

What about php ?

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

We found it redirected to b.php.
The following code is not executed after the redirect is executed in ASP.
and PHP continues to execute the following code after executing the header.
In this respect the header redirection in PHP is not as redirected as in ASP. Sometimes after we redirect, we can't execute the following code:

In general, we use
if (...)
Header ("...");
Else
{
...
}
But we can simply use the following methods:
if (...)
{Header ("...");



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.