使用PHP进行页面跳转可以使用header()
函数,header("Location: https://www.example.com");
。
PHP页面跳转URL
单元表格
功能 | PHP代码 |
页面跳转到指定URL | header('Location: http://www.example.com'); |
页面跳转到当前URL的相对路径 | header('Location: ./index.php'); |
页面跳转到上一级目录 | header('Location: ../index.php'); |
页面跳转到根目录 | header('Location: /index.php'); |
相关问题与解答
问题1:如何在PHP中实现页面跳转?
答:在PHP中,可以使用header()
函数实现页面跳转,要跳转到指定的URL,可以使用以下代码:
header('Location: http://www.example.com');
如果要跳转到当前URL的相对路径,可以使用以下代码:
header('Location: ./index.php');
问题2:如何实现页面跳转到上一级目录?
答:要实现页面跳转到上一级目录,可以使用以下代码:
header('Location: ../index.php');
请注意,这里的..
表示上一级目录。