Home > Article > Backend Development > Can't jump after php redirection
There are three ways to redirect web page jumps in PHP. The following is a detailed introduction to you.
The first one: Use the header() function for redirection, which is what I use most. (Note! There cannot be a space between location and ":", otherwise it will have no effect!)
<?php header('content-type:text/html;charset=uft-8); //重定向页面 header('location:index.php'); ?>
Second: Use the meta tag in the HTML header to 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>
or
<?php header('content-type:text/html;charset=utf-8'); $url='index.php'; ?> <!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>
th Three types: Use javascript to jump
<?php header('content-type:text/html;charset=utf-8'); $url='index.php'; //立即跳转至目标页面 echo <script>window.location.href='$url';</script>; ?>
The above content is for reference only!
Recommended video tutorial: PHP video tutorial
The above is the detailed content of Can't jump after php redirection. For more information, please follow other related articles on the PHP Chinese website!