我正在使用以下函数在特定任务后重定向一个人(例如:登录后、注销后、搜索后等)代码如下:
<?php
class common {
/* Redirect to another page
* $url= Url to go
*/
function redirection($url){
header("location: $url");
exit();
}
// Some other function below
?>
但现在我正在处理这个类与不同主机的许多项目(传销项目)。我现在有个问题。对于某些服务器,它可以按我的预期工作,但在其他一些服务器中,它不会重定向。如果我启用error_reporting(E_ALL)
;我发现了一个通知headers are already send
。所以我很困惑我现在能做什么而不是header()
功能。我也尝试了下面的代码
<?php
function redirection($url){
echo "<div align='center'><a href='$url' target='_top'><img src='../img/proceed.jpg' alt='Proceed>>' align='absmiddle' border='0'></a></div>";
exit();
}
?>
但这是不可取的,因为每个人都希望自动重定向。我的服务器都是windows和linux。请帮助我任何人