I got an error of:
"Warning: Cannot modify header information - headers already sent by (output started at ..."
My script was running fine before I move to another server, the error happens. My script is like:
<?php
if($SomeCondition)
{
header("location:http://www.yahoo.com");
return;
}
?>
After remove 'return', my scripts have not any error, the correct script should be:
<?php
if($SomeCondition)
{
header("location:http://www.yahoo.com");
}
?>
This is quite usual to a C programmer, but not works on some php server. Some other said after header there should be no more other scripts, because it has already redirected.
----------------------------------------------------------------------------------------------------------------------------------------------------
我的一个php script突然在换了主机后出错
"Warning: Cannot modify header information - headers already sent by (output started at ..."
我的script:
<?php
if($SomeCondition)
{
header("location:http://www.yahoo.com");
return;
}
?>
在换主机前好好的,后来把return去掉了就好了,看来各主机商之间的php还是有差别,即使版本相同. |