在 PHP 中,使用 header() 函数可以实现页面的跳转。
示例:
<?php
// 跳转到指定的 URL
header("Location: http://www.example.com");
// 跳转到当前域名下的某个页面
header("Location: /path/to/page.php");
// 跳转到上一级页面
header("Location: ../previous/page.php");
?>
请注意,header() 函数必须在发送任何输出之前调用,否则会导致错误。同时,跳转后应该使用 exit 或 die 函数终止脚本的执行,以确保页面立即跳转。
示例:
<?php
header("Location: http://www.example.com");
exit;
?>
以上是 PHP 中实现页面跳转的方法,希望对你有帮助。
上一篇:php根据时间合并数组
下一篇:搭建单机php服务器
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站