简体   繁体   中英

PHP output buffer is not empty?

I have this peculiar problem. I am making an AJAX call to a PHP page. In case of error I am returning the string "error" to success: function(msg) ie msg will have the value "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") . I have to put ob_clean() to clear out the output buffer. Then it returns "error" without line break. I checked but my PHP function is not outputting anything before the "error". 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 ?>

As PhpMyCoder propsed - you could also not put ?> in the end of the file at all. Php allows doing that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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