PHP setcookie() 报 cannot modify header information 错误的解决方法
来源:互联网 发布:python agv[] 编辑:程序博客网 时间:2024/05/15 23:46
今天用到一段别人的程序,运行时出错,提示:Warning: Cannot modify header information - headers already sent by....,打开文件,发现报错的那一行是setcookie()函数的一个设置,平常常用session,对cookie不老熟的,找资料,终于解决了。先说一下问题发生的原因啊:
1、使用setcookie必须在<html>标签之前;
2、使用setcookie之前,不可以使用echo输入内容;
3、直到网页被加载完后,cookie才会出现;
4、setcookie必须放到任何资料输出浏览器前,才送出;
就是因为上面这些原因,才导致了出错,所以解决办法是在输出内容之前,产生cookie,可以在程序的最上方加入函数 ob_start();
ob_start :打开输出缓冲区
函数格式:void ob_start(void)
说明:当缓冲区激活时,所有来自PHP程序的非文件头信息均不会发送,而是保存在内部缓冲区。为了输出缓冲区的内容,可以使用ob_end_flush()或flush()输出缓冲区的内容。
0 0
- PHP setcookie() 报 cannot modify header information 错误的解决方法
- PHP setcookie() 报 cannot modify header information 错误的解决方法
- PHP setcookie() cannot modify header information 的解决方法
- php setcookie 之 Cannot modify header information 解决方法
- PHP经典header错误"Cannot modify header information"的解决方法(转)
- PHP中 header错误问题 的解决方法Cannot modify header information
- PHP中 header错误问题 的解决方法Cannot modify header information
- php出现Cannot modify header information问题的解决方法大全
- php出现Cannot modify header information问题的解决方法大全
- php出现Cannot modify header information问题的解决方法
- php出现Cannot modify header information问题的解决方法大全
- php出现Cannot modify header information问题的解决方法大全
- PHP出现"Cannot modify header information"警告的解决方法
- Cannot modify header information的解决方法
- "Warning: Cannot modify header information”的解决方法!
- setcookie() Cannot modify header information - headers already sent by错误解决办法
- PHP错误Warning: Cannot modify header information - headers already sent by解决方法
- php错误"Cannot modify header information - headers already sent by"
- [Android]attrs.xml文件中属性类型format值的格式
- UVA1631 - Locker
- ^(^=)是什么以及他的运算规则
- Toast.makeText(MainActivity.this, R.string.alert, Toast.LENGTH_SHORT).show(); 解释
- java 面试一定会面试的题目
- PHP setcookie() 报 cannot modify header information 错误的解决方法
- HDU 1150 Machine Schedule匈牙利算法
- 在win7上安装AutoCAD2006
- Android Studio 提示 android.support.v4.app 不存在
- 替换PopUpWindow(解决焦点获取问题)实现顶部筛选菜单(顶部不变,底部阴暗)
- oracle select count(*) 优化
- SVN学习笔记9 -- SVN Eclipse 插件安装-- 新的旅程
- ServletContextListener使用详解
- php正则判断字符串是否包含中文或特殊字符等