Cannot modify header information - headers already sent by

在做php中设置cookie时出现Cannot modify header information - headers already sent by的错误,初步认为是清理缓存错误,后来查找网络发现不是,是php的一些基本尝试错误,解决如下



在PHP里Cookie的使用是有一些限制的。

1、使用setcookie必须在<html>标签之前

2、使用setcookie之前,不可以使用echo输入内容

3、直到网页被加载完后,cookie才会出现

4、setcookie必须放到任何资料输出浏览器前,才送出