How to redirect page jump in php?

青灯夜游
Release: 2023-02-28 19:00:02
Original
2890 people have browsed it

How to redirect page jump in php? The following article will introduce to you how to redirect web pages in PHP. It has certain reference value. Friends in need can refer to it. I hope it will be helpful to everyone.

How to redirect page jump in php?

Methods to redirect web pages in PHP

First: Use the header() function for redirection

Note: There cannot be a space between locationhe and ":", otherwise it will have no effect!

<?php
    header(&#39;content-type:text/html;charset=uft-8);
    //重定向页面
    header(&#39;location:index.php&#39;);
?>
Copy after login

Second: Use the meta tag in the HTML header

Define http-equiv=refresh and content=”The time it takes to jump (in seconds) ); url = jump address”

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    //跳转页面,跳转时间:3秒钟,目标地址:index.php
    <meta http-equiv="refresh" content="3;url=index.php">
    <title>skip...</title>
</head>
Copy after login

or

<?php
header(&#39;content-type:text/html;charset=utf-8&#39;);
$url=&#39;index.php&#39;;
 ?>
 <!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    //跳转页面,跳转时间:2秒钟,目标地址:index.php
    <meta http-equiv="refresh" content="2;url=<?php echo $url; ?>">
    <title>skip...</title>
</head>
Copy after login

The third type: use javascript to jump

<?php
header(&#39;content-type:text/html;charset=utf-8&#39;);
$url=&#39;index.php&#39;;
//立即跳转至目标页面
echo <script>window.location.href=&#39;$url&#39;;</script>;
?>
Copy after login

More related knowledge, Please pay attention to PHP中文网! !

The above is the detailed content of How to redirect 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!