我了解只要数据已发送到浏览器,就无法修改 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/