Home >Backend Development >PHP Tutorial > 开启OB缓存无效?求解。该如何处理

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

WBOY
WBOYOriginal
2016-06-13 12:42:51849browse

开启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

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn