How to jump to page in php

(*-*)浩
Release: 2023-02-24 12:56:01
Original
5106 people have browsed it

The problem of PHP jumping to a specified page is usually seen in website construction requirements. For example, we need to jump from one page to another to achieve a certain function or effect. In fact, there are many ways to jump pages in PHP, so this article will introduce to you, what methods can be used to jump pages in PHP?

How to jump to page in php

First we need to understand two knowledge points:

1: The header() function is used to jump pages in PHP A very simple method. The main function of the header() function is to output the HTTP protocol header (header) to the browser. (Recommended learning: PHP programming from entry to proficiency)

2: The Meta tag is a tag in HTML responsible for providing document meta-information. Use this in PHP programs Tags can also achieve page jumps.

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 takes for the page to jump to the specified URL.

Then php jumps to the header() function of the specified page. The specific usage example code is as follows:

void header (string string [,bool replace [,int http_response_code]])//header()函数的定义

<?php

//重定向浏览器

header("Location: https://www.cnblogs.com/furuihua/");

//确保重定向后,后续代码不会被执行

exit;

?>
Copy after login

php jumps to the Meta tag of the specified page. The sample code is as follows:

<meta http-equiv = "refresh"  content = "1;url=https://www.cnblogs.com/furuihua/" >
<?php

$url= "https://www.cnblogs.com/furuihua/" ;?>

<html>

<head>

    <meta   http-equiv = "refresh"   content ="1;

url = <?php echo $url;  ?> ">

</head>

<body>

页面只停留一秒……

</body>

</html>

//meta.php实现在该页面中停留一秒后页面自动跳转到https://www.cnblogs.com/furuihua/
Copy after login

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

Related labels:
php
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