Home > Backend Development > PHP Problem > How to implement page jump in php

How to implement page jump in php

王林
Release: 2023-03-03 14:44:01
Original
2217 people have browsed it

How to implement page jump in php: You can use the header() function to achieve it. The specific usage is as follows: [header("Location:https://www.xxx.com");]. It should be noted that there cannot be any output before using the header.

How to implement page jump in php

#It is a very simple method to implement page jump through the header() function.

(Recommended tutorial: php graphic tutorial)

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

The function syntax is as follows:

void header (string string [,bool replace [,int http_response_code]])
Copy after login

Parameter description:

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

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

(Recommended video tutorial: php video tutorial)

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.

Code implementation:

< ?php 
//重定向浏览器 
header("Location: https://www.php.cn/"); 
//确保重定向后,后续代码不会被执行 ......
?>
Copy after login

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template