WordPress错误:Cannot modify header information

Warning: Cannot modify header information – headers already sent by (output started at /www/htdocs/xiaokyun/wp-config.php:1) in /www/htdocs/xiaokyun/wp-login.php on line 255

Warning: Cannot modify header information – headers already sent by (output started at /www/htdocs/xiaokyun/wp-config.php:1) in /www/htdocs/xiaokyun/wp-login.php on line 267
Warning: Cannot modify header information – headers already sent by (output started at /www/htdocs/xiaokyun/wp-config.php:1) in /www/htdocs/xiaokyun/wp-includes/pluggable.php on line 649
Warning: Cannot modify header information – headers already sent by (output started at /www/htdocs/xiaokyun/wp-config.php:1) in /www/htdocs/xiaokyun/wp-includes/pluggable.php on line 650
Warning: Cannot modify header information – headers already sent by (output started at /www/htdocs/xiaokyun/wp-config.php:1) in /www/htdocs/xiaokyun/wp-includes/pluggable.php on line 651
Warning: Cannot modify header information – headers already sent by (output started at /www/htdocs/xiaokyun/wp-config.php:1) in /www/htdocs/xiaokyun/wp-includes/pluggable.php on line 850
上网搜索了一下,大致有两种解决方案,整理了一下,主要的造成的原因和解决办法如下:
1.php.ini配置问题,解决办法:打开 php.ini 然后把 output_buffering 设为 on ,重启appache即可。
2.使用windows记事本编辑的wp-config文件造成(UTF8编码和BOM冲突),解决办法:使用Notepad++、UltraEdit、EditPlus等编辑器编辑文件,一般的主机管理系统自带的编辑功能也不错。
或者,将wp-config.php另存为ANSI编码。
如果是安装PHP其他程序或者自己写的程序出现以上问题,除了以上两种可能,还有可能是setcookie的问题,解决办法是在输出内容之前,产生cookie,可以在程序的最上方加入函数 ob_start(); 格式如下:
ob_start :打开输出缓冲区
函数格式:void ob_start(void)