php中實(shí)現(xiàn)重定向的方法:1、使用“header('location:跳轉(zhuǎn)地址');”語句;2、使用“echo '<meta http-equiv="refresh" content="跳轉(zhuǎn)秒數(shù);url=跳轉(zhuǎn)地址">';”語句。
本教程操作環(huán)境:windows7系統(tǒng)、PHP7.1版、DELL G3電腦
什么是重定向?
重定向(Redirect)就是通過各種方法將各種網(wǎng)絡(luò)請求重新定個方向轉(zhuǎn)到其它位置(如:網(wǎng)頁重定向、域名的重定向、路由選擇的變化也是對數(shù)據(jù)報(bào)文經(jīng)由路徑的一種重定向)。
php中如何實(shí)現(xiàn)重定向?
方法1:header()函數(shù)
header('location:https://www.php.cn/');
方法2:meta標(biāo)簽
echo '<meta http-equiv="refresh" content="1;url=https://www.php.cn/">';
方法3:script標(biāo)簽
echo '<script>window.location.href="https://www.php.cn/"</script>';
推薦學(xué)習(xí):《PHP視頻教程》