扫码关注官方订阅号
PHP中,根据网址跳转不同的页面如何写
例如
当用户访问
https://www/?a=*
自动跳转为
https://www/?b=*
PHP代码应该如何写?
ps:等号后面是任意数字,根据不同的数字,跳转到不同的页面
获取到数字根据数字判断header跳转
header
方法比较多:
php的header
js的location.href
location.href
某些php框架自带了跳转函数,比如tp、ci的Redirect函数等
Redirect
<?php $arg = isset($_GET['a']) ? $_GET['a'] : ''; if( !empty($arg) ) { switch($arg) { case 'one': header('Location:'.$toUrl); //$toUrl为要跳转的链接 break; case 'two': /* your code here */ default: break; } }
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
获取到数字
根据数字判断
header跳转方法比较多:
php的
headerjs的
location.href某些php框架自带了跳转函数,比如tp、ci的
Redirect函数等