Home  >  Article  >  Backend Development  >  How to implement jump between PHP server pages_PHP tutorial

How to implement jump between PHP server pages_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:17:04865browse

(Note that it is not a client-side jump using header, js, etc.)

Copy code The code is as follows:

function server_transfer($dest)
{
global ...; // List the variables of this page or customized global variables that you want to use in the new page here
include $dest; / / Run new script
exit; // Exit this script
}


Note:
1. Any data output before the jump will be in the new page Display, unless the ob_start buffer is used, can be cleared before jumping, so that there is no impact on each other.
2. Since the new page runs within a custom function scope, the variables defined on this page will not affect the new page. page, this is both an advantage and a disadvantage.
3. New pages can still use super-global variables such as $_POST to access variables that originally belong to this page. You need to pay attention when writing code.
4. You must consider this page The problem of repeated inclusion with new pages. If both pages contain the same page, such as headers and footers, require_once must be used.

In short, jumps can be done, but programmers must be aware that everything has happened. What, otherwise it's easy to get some weird results.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/325778.htmlTechArticle(Note that it is not a client jump made by header, js, etc.) Copy the code as follows: function server_transfer( $dest) { global ...; // Put the variables of this page that you want to use in the new page or...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn