Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use php to realize Page Jump

2025-01-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

How to use php to achieve page jump, in view of this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.

The way to use php to achieve page jump is to use header () function to achieve jump, such as [header ("Location: http:// www.xxxxx.com");] the operating environment of this paper: windows10 system, php 7, thinkpad T480 computer.

It is very simple to implement a page jump in php. For example, we can use the header () function or the Meta tag to achieve a page jump.

Let's take a look at these two ways to jump pages.

Method 1: header () function

The header () function is a very simple way to jump pages in PHP. 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:

Void header (string string [, bool replace [, int http_response_code]])

The optional parameter replace indicates whether to replace the previous similar header or to add a header of the same type, which is replaced by default. The second optional parameter, http_response_code, forces the corresponding HTTP code to be set to the specified value. The header of the Location type in the header function is a special header call, which is often used to implement a page jump.

Note:

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

two。 You cannot have any output before using header.

The PHP code after 3.header is also executed. For example, redirect the browser to Ice Love

< ?php //重定向浏览器 header("Location: http:// www.baidu.com"); //确保重定向后,后续代码不会被执行 exit;?>

Method 2: Meta tag

The Meta tag is the tag responsible for providing document meta-information in HTML. Using this tag in the PHP program, you can also achieve 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 according to the value specified by content.

If you set content= seconds; url= URL, it defines how long it takes for the page to jump to the specified URL. For example, use the meta tag to automatically jump to Ice Love after the vaccine.

< meta http-equiv = "refresh" content = "1;url= http:// www.baidu.com " >

For example, the following program meta.php implements that the page automatically jumps to bbs.lampbrother.net after staying in the page for one second.

< ?php $ url = " http://www.baidu.com" ; ?>

< html >

< head >

< meta http-equiv = "refresh" content ="1; url = < ?php echo $url; ?>

">

< /head >

< body >

The page only stays for one second.

< /body >

< /html >

This is the answer to the question about how to use php to achieve page jump. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 225

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report