PHP页面跳转出错,求助。

kisshujinwen 2010-07-21 10:54:33
Warning: Cannot modify header information - headers already sent by (output started at E:\wamp\www\index.php:9) in E:\wamp\www\index.php on line 10
错误原因是这个,我程序就一个
<?php
header('Location: http://baidu.com');
?>
请问哪儿错了?
...全文
69 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
ihefe 2010-07-21
  • 打赏
  • 举报
回复

<?php
header("location: /abc.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>


</body>
</html>
//楼上都说了。我贴下代码
kisshujinwen 2010-07-21
  • 打赏
  • 举报
回复
哦,这样啊,谢谢候鸟了。
CunningBoy 2010-07-21
  • 打赏
  • 举报
回复
直接这样就可以了,你前面的内容都没啥用
<?php
header("location: /abc.php");
?>
kisshujinwen 2010-07-21
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 amani11 的回复:]
一大段代码,那不是输出?

放在最开头。header了,最好exit
[/Quote]

那请问我该这么写啊?我是新手,大一刚学完C,请求指点
amani11 2010-07-21
  • 打赏
  • 举报
回复
一大段代码,那不是输出?

放在最开头。header了,最好exit
kisshujinwen 2010-07-21
  • 打赏
  • 举报
回复
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<?php
header("location: /abc.php");
?>


</body>
</html>

这就是我整个程序,我在前面没有输出。
CunningBoy 2010-07-21
  • 打赏
  • 举报
回复
header之前不能有echo输出,不能已经有header()或者其他输出语句。

21,893

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧