Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
389 views
in Technique[技术] by (71.8m points)

php中header函数前面不能有输出语句

在我的印象里,设置header函数前面不能有任何echo print 等输出语句,否则会报错
image.png
为什么我运行这段代码,正常运行?
image.png
当我在代码前面关闭缓冲,才会报错
image.png
没搞懂的是我都没有ob_start(),为什么一开始不会报错?现在php默认自动开启缓冲?求大佬解答,感谢


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

https://www.php.net/manual/zh...

如果开启了 output_buffering 则会等到buffer写满之后才会向浏览器发送


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...