php跳转 头部错误 headers already sent by修正
的有关信息介绍如下:菜鸟版:php跳转头部错误Warning: Cannot modify header information - headers already sent by (output started at 修改
众所周知以上错误是由于在文件的第一个
那么菜鸟以以下更正代码:
原错误文件:
PHP跳转代码别人帮我写的,目的是跳转,文件为go.php当网址输入go.php?id=baidu的时候就跳转到www.baidu.com
运行后发生错误Warning: Cannot modify header information - headers already sent by (output started at /data/home/。。。。。。/go.php:8) in /data/home/。。。。。。/go.php on line 10
百度得知需要改php.ini但新主机改这个很麻烦。。求有没有直接在以上文件php代码里修改以上错误的方法?
代码:
$id=$_GET["id"];
if($id=="taobao"){Header("Location:http://www.taobao.com");
}
?>
运行错误提示:Warning: Cannot modify header information - headers already sent by (output started at /data/home/。。。。。。/go.php:8) in /data/home/。。。。。。/go.php on line 10
菜鸟法纠正:
去掉所有html代码,直接用php代码:
$id=$_GET["id"];
if($id=="taobao"){Header("Location:http://www.taobao.com");
}
?>
建议法:参考高手写的代码,处理Warning: Cannot modify header information - headers already sent by (output started at 错误:
完整代码:
case 'taobao':
echo "";
break;
case 'baidu':
echo "";
break;
case 'others':
echo "";
break;
}
?>