时间:2021-07-01 10:21:17 帮助过:21人阅读
Warning: Cannot modify header information – headers already sent by (output started at C:\xampp\htdocs\b.php:2) in … on line …
但因为当时php.ini设置成了error_reporting = E_ALL & ~E_NOTICE,于是没有任何提示,所以开发的时候还是建议设成error_reporting = E_ALL 方便观察到一些异常情况。
附一个setcookie用法实例
a.php
代码如下:
setcookie("page", "a.php");
$page = $_COOKIE["page"] ? $_COOKIE["page"] : "unknown";
echo "From " . $page . "
";
?>
This is a.php. Go to b.php
b.php
代码如下:
setcookie("page", "b.php");
$page = isset($_COOKIE["page"]) ? $_COOKIE["page"] : "unknown";
echo "From " . $page . "
";
?>
This is b.php. Go to a.php
http://www.bkjia.com/PHPjc/323842.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/323842.htmlTechArticle结果碰到一个问题,setcookie设置了Cookie并没有生效,在浏览器端也没有看到。查了一下,原来是setcookie是通过HTTP请求响应的Header来完成的,...