Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter inserts extra line in response
#1

[eluser]Unknown[/eluser]
In all of my responses, there is a newline before the actual content. For example, let's say I have the following controller:

Code:
class Api extends CI_Controller {
  function upvote() {
    $slug = $this->input->get("slug");
    header("Content-Type: application/json");
    echo $slug;
  }
}

When I hit this resource, there's a newline inserted in the response. Like so:

Code:
1
2 this-is-the-slug

Is this a bug in the framework or am I doing something wrong?

Thanks!
#2

[eluser]Victor Michnowicz[/eluser]
I think saving your files as UTF8 with a BOM may cause something like this. If this is the case, you gotta get rid of that BOM in all the files you have saved.
#3

[eluser]Unknown[/eluser]
That wasn't it, but I figured out the issue.

An extra space will be included for each included library that closes its PHP tag. I left all the tags open-ended and it fixed the issue.




Theme © iAndrew 2016 - Forum software by © MyBB