PHP server page Jump implementation

Source: Internet
Author: User
In ASP, Server. Transfer can be used to implement Server-side redirection. Although PHP does not have such a function, it is not difficult to implement similar redirection.

In ASP, Server. Transfer can be used to implement Server-side redirection. Although PHP does not have such a function, it is not difficult to implement similar redirection.

(Note that it is not a client jump using header, js, or other methods)

The Code is as follows:
Function server_transfer ($ dest)
{
Global...; // list the variables on the current page or custom global variables you want to use on the new page.
Include $ dest; // run the new script
Exit; // exit the script
}


Note:
1. If any data output before the jump is displayed on the new page, it can be cleared before the jump unless the ob_start buffer is used. This will not affect each other.
2. Because the new page runs in a custom function scope, the variables defined on this page will not affect the new page. This is both a benefit and a disadvantage.
3. On the new page, you can still use super global variables such as $ _ POST to access the variables originally on this page. Note the need to write code.
4. to repeat the content of this page and the new page, if both pages contain the same page, such as the header and footer, use require_once.

All in all, the jump can be done, but the programmer must know what happened, otherwise it is easy to get some strange results.

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.