php中重定向网页跳转方法总结案例教程
时间:2021-12-30 来源:互联网
这篇文章主要介绍了php中重定向网页跳转方法总结案例教程,本篇文章通过简要的案例,讲解了该项技术的了解与使用,以下就是详细内容,需要的朋友可以参考下
PHP中重定向网页跳转页面的方法(共三种)
第一种:利用header()函数进行重定向,这也是我用的较多的。(注意!locationhe和“:”之间不能有空格,否则无作用!)
<?php header('content-type:text/html;charset=uft-8); //重定向页面 header('location:index.php'); ?>
第二种:利用HTML 头部中的 meta标签,定义http-equiv=refresh 和content=”跳转花费的时间(秒为单位);url=跳转地址”
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> //跳转页面,跳转时间:3秒钟,目标地址:index.php <meta http-equiv="refresh" content="3;url=index.php"> <title>skip...</title> </head>
或者
<?php header('content-type:text/html;charset=utf-8'); $url='index.php'; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> //跳转页面,跳转时间:2秒钟,目标地址:index.php <meta http-equiv="refresh" content="2;url=<?php echo $url; ?>"> <title>skip...</title> </head>
第三种:利用javascript进行跳转
<?php header('content-type:text/html;charset=utf-8'); $url='index.php'; //立即跳转至目标页面 echo <script>window.location.href='$url';</script>; ?>
以上就是PHP中重定向页面的三种方法。
到此这篇关于php中重定向网页跳转方法总结案例教程的文章就介绍到这了,更多相关php中重定向网页跳转内容请搜索PHP爱好者以前的文章或继续浏览下面的相关文章希望大家以后多多支持PHP爱好者!
相关阅读更多 +
-
以太坊ETF超越比特币?贝莱德ETHA突破100亿美元大关 2025-07-27
-
-
比特币买豪宅》佳士得开设加密货币房地产部门,隐私与效率吸引富豪买家 2025-07-27
-
香港稳定币条例 8/1 生效:牌照、监管、银行託管…重点速看 2025-07-27
-
KGNCloud 重新定义2025年数字财富——更智能、更快速、更安全的加密挖矿未来 2025-07-27
-
在另类币季节的狂热中,XRP惊现1.55亿美元巨额资金流入 2025-07-27
最近更新