首页 > php教程 > php手册 > 正文

php中使用header函数后,页面提示:Warnging: Cannot modify hea

php中文网
发布: 2016-06-06 19:53:57
原创
1585人浏览过

Warning: Cannot modify header information - headers already sent by 的原因 我的php程序调用了header(Location: www.baidu.com );函数, 运行后出现出现 Warning: Cannot modify header information - headers already sent by 的页面警告。 发现原来是

 

Warning: Cannot modify header information - headers already sent by 的原因

我的php程序调用了header("Location:www.baidu.com");函数,

运行后出现出现 Warning: Cannot modify header information - headers already sent by 的页面警告。

发现原来是我的php.ini里面的配置的问题,

默认的php.ini文件中,output_buffering指令选项的默认值为off。

立即学习PHP免费学习笔记(深入)”;

把它设为4096就解决了显示提示warning错误的提示。.

php.ini 文件对 output_buffering指令选项做了详细说明如下:

芦笋演示
芦笋演示

一键出成片的录屏演示软件,专为制作产品演示、教学课程和使用教程而设计。

芦笋演示 34
查看详情 芦笋演示

 

  94 ; Output buffering allows you to send header lines (including cookies) even
  95 ; after you send body content, at the price of slowing PHP's output layer a
  96 ; bit.  You can enable output buffering during runtime by calling the output
  97 ; buffering functions.  You can also enable output buffering for all files by
  98 ; setting this directive to On.  If you wish to limit the size of the buffer
  99 ; to a certain size - you can use a maximum number of bytes instead of 'On', as
 100 ; a value for this directive (e.g., output_buffering=4096).
 101 #output_buffering = Off
 102  output_buffering = 4096
登录后复制

最后,重启,使修改后的配置文件生效。

在Linux下,

如果因PHP命令行而修改php.ini 则不需要重启;

如果因Apache而修改php.ini,则需要重启apache服务;

总之,就是那个服务使用了php,就重新启动该服务,就可以了。


 

相关标签:
php
PHP速学教程(入门到精通)
PHP速学教程(入门到精通)

PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号