LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 1051|回复: 6

php中header不能修改的警告 为什么呢

[复制链接]
发表于 2004-12-1 14:36:42 | 显示全部楼层 |阅读模式
Warning: Cannot modify header information - headers already sent by (output started at D:\Program Files\Apache Group\Apache2\htdocs\zend\index.php:6) in D:\Program Files\Apache Group\Apache2\htdocs\zend\index.php on line 7

Warning: Cannot modify header information - headers already sent by (output started at D:\Program Files\Apache Group\Apache2\htdocs\zend\index.php:6) in D:\Program Files\Apache Group\Apache2\htdocs\zend\index.php on line 8
发表于 2004-12-2 09:58:01 | 显示全部楼层
在header送出之前不能有echo
 楼主| 发表于 2004-12-4 02:58:58 | 显示全部楼层
<?
if(!isset($PHP_AUTH_USER))
{
Header("WWW-Authenticate: Basic realm=\"My Realm\"");
Header("HTTP/1.0 401 Unauthorized");
echo "Text to send if user hits Cancel button\n";
exit;
}
else
{
if ( !($PHP_AUTH_USER=="tnc" && $PHP_AUTH_PW=="nature") )
{
// 如果是错误的用户名称/密码对,强制再验证
Header("WWW-Authenticate: Basic realm=\"My Realm\"");
Header("HTTP/1.0 401 Unauthorized");
echo "ERROR : $PHP_AUTH_USER/$PHP_AUTH_PW is invalid.";
exit;
}
else
{
echo "Welcome tnc!";
}
?>


沒有任何問題啊
為什麼呢
 楼主| 发表于 2004-12-4 03:00:05 | 显示全部楼层
我還重啟過很多次
還是不行的
发表于 2004-12-4 15:10:43 | 显示全部楼层
把这段程序放到文件首部呢?
 楼主| 发表于 2004-12-4 15:46:31 | 显示全部楼层
我改成了這個樣子:

<?php
header('WWW-Authenticate: Negotiate');
header('WWW-Authenticate: NTLM', false);
?>
<html>
<body>
<body>
</html>


現在在Zend裡面的輸出是:
Status: 401

Content-type: text/html

X-Powered-By: PHP/5.0.0

WWW-Authenticate: Negotiate

WWW-Authenticate: NTLM



<html>
<body>
<body>
</html>


而在自己Apacke上打開的網友上依舊是:
Warning: Cannot modify header information - headers already sent by (output started at D:\Program Files\Apache Group\Apache2\htdocs\zend\index3.php:2) in D:\Program Files\Apache Group\Apache2\htdocs\zend\index3.php on line 3

Warning: Cannot modify header information - headers already sent by (output started at D:\Program Files\Apache Group\Apache2\htdocs\zend\index3.php:2) in D:\Program Files\Apache Group\Apache2\htdocs\zend\index3.php on line 4


正是奇怪了
发表于 2004-12-7 16:39:21 | 显示全部楼层
你的認證是標準的HTTP頭嗎?不像啊?要不直接用meta輸出吧
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表