Home>Article>Backend Development> How to redirect web pages in PHP
How to redirect web pages in PHP: 1. Use the [header()] function to redirect; 2. Use the meta tag in the HTML header; 3. Use javascript to jump.
[Related learning recommendations:php graphic tutorial]
How to redirect web pages in PHP:
hhw: Use the first method to redirect: http://127.0.0.1/tp5 Simplified tohttp://127.0.0.1
, that is, write the index.php file in the www directory to the php code in the first type:
or directly:
The first one: Use the header() function for redirection, which is what I use most. (Note! There cannot be a space between locationhe and ":", otherwise it will have no effect!)
Second: Use the meta tag in the HTML header to define http-equiv=refresh and content="jump The time it takes to transfer (in seconds); url = jump address”
//跳转页面,跳转时间:3秒钟,目标地址:index.phpskip...
or
//跳转页面,跳转时间:2秒钟,目标地址:index.phpskip...
The third way: use javascript to jump
window.location.href='$url';; ?>
Relevant learning recommendations:php programming(video)
The above is the detailed content of How to redirect web pages in PHP. For more information, please follow other related articles on the PHP Chinese website!