I am porting an application over from Cakephp 1.2 to 4.3
I have an action which outputs a binary (BIFF format) XLS file via its view.
But I have found that the generated output contains 3 leading bytes 0A 0D 0A before the BIFF header
I have tried removing everything from both the layout and the view template, and I still end up with the 3 bytes 0A 0D 0A (and of course nothing else).
If I try putting something like <?= "Blah" ?> as the only content of the layout, I get 0A 0D 0A the Blah then the BIFF header.
So wherever these 3 bytes are coming from, they are being emitted before the layout is rendered.
Does anyone have any suggestions to where these may be coming from?
Its also possible you’ve put the closing PHP tag ?> at the end of a file and there is a carriage return (0A 0D is Linefeed & Carriage return) after it. That will get sent as data to the webpage, as text after the closing tag is considered legitimate HTML data - so don’t use the closing PHP tag at the end of files.
Also, its odd the actual data is 0A 0D 0A. If the file is a Windows text file it has 0D 0A at the end of every line, always in pairs. Linux files have just 0A.
Therefore 0A 0D 0A is a mix - it should either be 0A 0D 0A 0D (Windows pairs of characters) or 0A 0A (Linux) - not having a stray 0A. Understandably you want neither, but this could show a bigger issue, that maybe you’ve edited a Linux text file in say Windows Notepad.
So its possible there’s a couple of things going on here to check for.