raksmart活动促销

分享

写回答

发帖

[提问] Cannot modify header information 问题

HostMonster HostMonster 2964 人阅读 | 3 人回复

发表于 2008-3-25 18:55:36 | 显示全部楼层 |阅读模式

HM上,我的一个代码如下:
  1. <?php
  2. # 让它在过去就"失效"
  3. header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');

  4. # 永远是改动过的
  5. header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');

  6. # HTTP/1.1
  7. header('Cache-Control: no-store, no-cache, must-revalidate');
  8. header('Cache-Control: post-check=0, pre-check=0', false);

  9. # HTTP/1.0
  10. header('Pragma: no-cache');
  11. ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  12. <html xmlns="http://www.w3.org/1999/xhtml">
  13. <?php
  14.     if(trim($_REQUEST["logout"])!=""){
  15.         setCookie("passed","",time()-7200);
  16.         header("Location: ./");
  17.         }
  18.     $passed=trim($_COOKIE["passed"]);
  19.     if($passed!="") $passed=true;
  20.     $screend=trim($_COOKIE["screen_display"]);
  21. ?>
复制代码

结果是一连串的错误:
Warning:  Cannot modify header information - headers already sent by (output started at /home...
之类的。
这个在我本地机上是没问题的,在DH上也没问题,但一到HM,就不行了,各位帮我看看,谢谢 !

回答|共 3 个

bingu

发表于 2008-3-25 20:27:33 | 显示全部楼层

setcookie之前不能有html

govo

发表于 2008-3-26 13:10:17 | 显示全部楼层

没有啊,即使我把setCookie放到最前面还是一样。

govo

发表于 2008-3-26 13:12:57 | 显示全部楼层

全部内容是:
Warning: Cannot modify header information - headers already sent by (output started at /path/index.php:1)
说第一行已经有东西输出了,但我这第一行什么没有啊,连空格也没有
您需要登录后才可以回帖 登录 | 注册

本版积分规则

HostMonster讨论

HostMonster
优惠码:优惠链接
介绍:HostMonster美国主机商成立于1996年,总部位于犹他州普罗沃,提供主机托管服务,在业内有比较有实力,而且口碑也不错。HostMonster美国主机性价比较高,而且基本不会额外收取费用,其无限型方案支持无限磁盘空间,无限带宽和电子邮件帐户,提供免费域名1个。
查看更多

govo

发表主题