I just found out, that all pages generated by CI, have 2 trailing whitespaces at the beginning of the page.
As i have a third-party accessing a page, which expects to have no trailing whitespaces, does somebody know how to prevent that behaviour?
A third-party app is visiting a method of my controller. This method will authenticate the visit.
The third-party app expects, to have 0 returned for success and anything else is considered failure by the third-party app. So if i output 0 with 2 trailing whitespace like ’ 0’, it is considered failure.
I try to use
$data = 0; $this->output->set_output($data);
but this will generate output ’ 0’. Then i check other pages in my CI app (ususally output done by a view) and they all have 2 trailing white spaces.
Trimming will not work because $this->output->set_output($data); has to be the last call and that gives me 2 trailing white spaces
How are you determining that there are 2 trailing whitespaces?
I did this:
each both with and without CodeIgniter and neither time did I see any trailing whitespace.
Are you viewing the output through a browser or it’s source code view? Is it an AJAX response? I have a feeling that these trailing spaces are from something else and you don’t need to worry about them.
I don’t understand. Are these trailing spaces or leading spaces?
It sounds to me like the HTML source in the view has spaces in it. Remove them and everything should be fine. Failing that, it must be something in your code that’s doing it. I’m willing to bet that even an empty controller method will still output two spaces.
I determine the 2 white space by selecting the complete output in source view. You will not see them in browser view.
The third-party app visiting expects, to have a 0, 1, 2, 3, 4, 5, 6, 7 returned, as the result of my method. As the third-pasty app fails, i suppose the 2 trailing white spaces are the problem. No AJAX involved, not even a single HTML tag, just these codes. Not more, not less.
That seems to be a small thing, but IMHO this would be a serious flaw. IN ASP, Java or whatever i used in my work before, i had complete control over the output.
What makes things worse, it is not possible to bend the third-party app. So I have to make CI behave correctly…