首页 >后端开发 >php教程 >开启OB缓存无效?求解。该如何处理

开启OB缓存无效?求解。该如何处理

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB原创
2016-06-13 11:28:301104浏览

开启OB缓存无效???求解。
是这样的,php.ini的ob是关闭的,我直接运行下面的代码提示错误:

<?php<br />echo "ok";<br />header("content-type:text/html;charset=utf-8");<br />echo "ook";<br />?>

以后输出:
ok<br />Warning: <br />Cannot modify header information - headers already sent by (output started at C:\php\apache\htdocs\static\test.php:1) in C:\php\apache\htdocs\static\test.php on line 4<br />ook


加上ob_start()开启ob缓存,应该是没有错误了,我加上ob,代码如下:
<?php<br />ob_start(); <br />echo "ok";<br />header("content-type:text/html;charset=utf-8");<br />echo "ook";<br />?>


运行结果:
ok<br />Warning: Cannot modify header information - headers already sent by (output started at C:\php\apache\htdocs\static\test.php:1) in C:\php\apache\htdocs\static\test.php on line 4<br />ook

声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn