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

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

WBOY
Release: 2016-06-13 12:42:51
Original
846 people have browsed it

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

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

以后输出:
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
Copy after login


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


运行结果:
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
Copy after login

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template