简体   繁体   English

PHP输出缓冲区不为空?

[英]PHP output buffer is not empty?

I have this peculiar problem. 我有这个特殊的问题。 I am making an AJAX call to a PHP page. 我正在对PHP页面进行AJAX调用。 In case of error I am returning the string "error" to success: function(msg) ie msg will have the value "error". 如果出现错误,我将字符串“error”返回到success: function(msg)即msg将具有值“error”。 But for some reason it is sending back "error" but with a line break preceding it. 但由于某种原因,它发回“错误”,但在它之前有一个换行符。 And this fails the condition when i check if (msg=="error") . 当我检查if (msg=="error")时,这会失败。 I have to put ob_clean() to clear out the output buffer. 我必须把ob_clean()清除输出缓冲区。 Then it returns "error" without line break. 然后它返回“错误”而没有换行符。 I checked but my PHP function is not outputting anything before the "error". 我查了但是我的PHP函数在“错误”之前没有输出任何内容。 What can be the issue that the output buffer is not empty? 输出缓冲区不为空的问题是什么?

That happens because some of your php files has an empty line before <?php or after ?> 这是因为你的一些php文件在<?php或之后?>之前有一个空行

As PhpMyCoder propsed - you could also not put ?> in the end of the file at all. 正如PhpMyCoder所说 - 你根本不能把?>放在文件的最后。 Php allows doing that. Php允许这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM