header前echo为啥不报错

WBOY
Release: 2016-06-13 12:03:09
Original
1107 people have browsed it

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

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

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

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!