Home  >  Article  >  Backend Development  >  How to jump directly to the page in php

How to jump directly to the page in php

藏色散人
藏色散人Original
2021-07-23 09:20:0217438browse

How to directly jump to the page in php: 1. Jump through the header() function; 2. Jump through the Meta tag; 3. Jump through JavaScript.

How to jump directly to the page in php

The operating environment of this article: windows7 system, PHP7.1 version, DELL G3 computer

How to jump directly to the page with php?

Several implementation methods of PHP page jump

● PHP page jump 1. header() function

The header() function is used to perform page jump in PHP A very simple way to jump.

The main function of the header() function is to output the HTTP protocol header (header) to the browser.

The header() function is defined as follows:

How to jump directly to the page in php

The optional parameter replace indicates whether to replace the previous similar header or add a header of the same type. Default is replace.

The second optional parameter http_response_code forces the HTTP corresponding code to the specified value.

The Location type header in the header function is a special header call, often used to implement page jumps.

Note:

1. There cannot be a space between location and ":", otherwise it will not jump.

2. There cannot be any output before using the header.

3. The PHP code after the header will also be executed.

The code is as follows:

How to jump directly to the page in php

● PHP page jump 2. Meta tag

Meta tag is responsible for providing document meta-information in HTML Tag, using this tag in PHP program can also realize page jump.

If http-equiv is defined as refresh, when the page is opened, it will jump to the corresponding page within a certain period of time based on the value specified by the content.

If content="seconds;url=website" is set, it defines how long it will take for the page to jump to the specified URL.

The code is as follows:

How to jump directly to the page in php

##● PHP page jump 3. JavaScript

For example, this code can be placed in any legal part of the program Location.

The code is as follows:

How to jump directly to the page in php

The above are the three PHP page jump implementation methods we introduced to you.

Recommended learning: "

PHP Video Tutorial"

The above is the detailed content of How to jump directly to the page in php. For more information, please follow other related articles on the PHP Chinese website!

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