Home  >  Article  >  Backend Development  >  header前echo为啥不报错

header前echo为啥不报错

WBOY
WBOYOriginal
2016-06-13 12:03:091146browse

header前echo为什么不报错
不是说header前有输出就会报错吗?为什么下面这个代码正常呢

<?php<br /><br />echo "abc";<br />header("Location: http://www.baidu.com/");<br /><br />?>

------解决方案--------------------
当你的输出缓冲区打开时,就不会报错
查看 output_buffering 的值
------解决方案--------------------
ob_start() 打开的是用户输出缓冲区
而 output_buffering 是 php 系统输出缓冲区,php5.2及以前是默认关闭的
正因为一不留神就出错,所以php5.3及以后就默认打开了。

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