【发布时间】:2011-02-09 03:03:51
【问题描述】:
我是PHP新手,刚刚练习了PHP setcookie(),失败了。
http://localhost/test/index.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<?php
$value = 'something from somewhere';
setcookie("TestCookie", $value);
?>
</body>
</html>
http://localhost/test/view.php
<?php
// I plan to view the cookie value via view.php
echo $_COOKIE["TestCookie"];
?>
但是我运行index.php失败,IE这样的警告。
Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\test\index.php:9) in C:\xampp\htdocs\test\index.php on line 12
毫无疑问,我启用了我的 IE 6 cookie。
我上面的程序有什么问题吗?谢谢。
使用了 WinXP 操作系统和 XAMPP 1.7.3。
【问题讨论】:
标签: php http cookies httpresponse