<?php
// 使用 header() 函数进行重定向
header("Location: https://www.example.com");
exit();
?>header("Location: https://www.example.com");:这行代码用于发送一个 HTTP 头信息,告诉浏览器重定向到指定的 URL(在这个例子中是 https://www.example.com)。exit();:在调用 header() 函数后,通常会使用 exit() 或 die() 来终止脚本的执行,以确保后续代码不会被执行。如果你需要根据条件进行重定向,可以这样做:
<?php
if ($someCondition) {
    header("Location: https://www.example.com");
    exit();
}
?>这样可以根据 $someCondition 的值决定是否进行重定向。
上一篇:php strcmp
下一篇:php json 转数组
Laravel PHP 深圳智简公司。版权所有©2023-2043 LaravelPHP 粤ICP备2021048745号-3
Laravel 中文站