如何在输出中删除一个领先的新行到浏览器在codeigniter [英] How do you remove a leading newline in output to browser in Codeigniter

查看:138
本文介绍了如何在输出中删除一个领先的新行到浏览器在codeigniter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直有与出现在我的codeigniter浏览器输出一个换行符的问题。会发生什么事是我输出JSON数据,但有一个换行符之前的任何JSON数据,并且它是搞乱东西了。

I have been having issues with a newline appearing in my browser output with Codeigniter. What happens is I am outputting JSON data, but there is a newline character before any of the JSON data, and it is messing stuff up.

推荐答案

有可能你必须在你的PHP文件之一年底一些空白。这是一个pretty常见的问题,如果您使用结束标记>

Likely you have some whitespace at the end of one of your PHP files. It is a pretty common problem if you use the closing tag ?>.

您会希望您的搜索code文件并寻找> 与后一个换行符。关闭标签后得到的任何输出到浏览器。

You'll want to search your code files and look for a ?> with a newline character after it. Anything after a closing tag gets output to the browser.

作为一种习惯,我不使用在code文件结束标记因为这个原因,因为它们不是由PHP间preTER必需的。一些编码标准推荐这一点。那里是PHP code后/间额外的输出,我只使用它们的模板文件。

As a habit, I don't use closing tags in code files for this reason, as they are not required by the PHP interpreter. Some coding standards recommend this as well. I only use them in template files where there is additional output between/after the PHP code.

这篇关于如何在输出中删除一个领先的新行到浏览器在codeigniter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆