php - 发送 header 后重定向用户

标签 php redirect

我了解只要数据已发送到浏览器,就无法修改 header 。

有什么方法(使用 PHP)可以执行重定向以将用户带到另一个页面(显然不使用标题)

如果可以,请指点我一些文档好吗?

最佳答案

决定编写我自己的 php 函数来实现 javascript 重定向。请参阅下面的代码。

function redirect($url)
{
    $string = '<script type="text/javascript">';
    $string .= 'window.location = "' . $url . '"';
    $string .= '</script>';

    echo $string;
}

关于php - 发送 header 后重定向用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7066527/

相关文章:

php - MySQL 组运行速度太慢

php - 为 MongoDB php 创建实时 MySQL 解析器

HTTP:POST 请求收到 302,重定向请求应该是 GET 吗?

Linux Shell "Variable"用于文件输入 "<"

javascript - 更改 WP 插件中的 JS 函数

php - 如何在 Doctrine2 查询生成器中使用 'interval'

php - Carbon\Carbon 类的对象无法转换为 int

django - 使用基于类的 View (CBV) Django 2.1 Python 重定向页面

reactjs - 在 HEROKU 上从 http 重定向到 https

ruby-on-rails - rails 3 : instance variable not available after redirection