0

My template starts with <!DOCTYPE html> on the first line, but for some reason when I view source on the page that's rendered, it starts on line 2.

This isn't a big deal in HTML, but I'm trying to render some XML and I'm running into the same issue, except XML isn't forgiving like HTML and must start on the first line.

EDIT

Thank you for the comments! I am a fairly new developer and was not aware of the BOM. That being said, I use PhpStorm, and you can just right click on a folder, then click 'Remove BOM', which I have done.

After doing that I ran this terminal command I found someone post grep -rl $'\xEF\xBB\xBF' that outputs files in the directory that have the BOM character. There were a few files listed, and I've fixed them all except /vendor/doctrine/orm/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php. I've tried removing the BOM with PhpStorm, and haven't had any luck, so I opened the file with VIM and ran set nobomb like I found here: How do I remove  from the beginning of a file?, but it still comes out in the listing of the grep command above.

Community
  • 1
  • 1
chrislebaron
  • 269
  • 3
  • 14
  • 1
    Possible duplicate of [PHP include causes white space at the top of the page](http://stackoverflow.com/questions/10199355/php-include-causes-white-space-at-the-top-of-the-page) – Vamsi Krishna B May 09 '16 at 18:51
  • This is not normal behavior, you should look at the possibility of the existence of a BOM as Vamsi suggested this is similar to. Does this happen for All views or just 1 in particular? – Chase May 10 '16 at 00:52
  • I've edited my question to include fixes for BOM issues that I have tried. – chrislebaron May 10 '16 at 15:32
  • But the problem disappeared or no? – malcolm May 10 '16 at 15:54
  • No, it's still happening. I can't seem to get the BOM removed from /vendor/doctrine/orm/lib/Doctrine/ORM/Query/TreeWalkerAdapter.php – chrislebaron May 10 '16 at 17:14
  • Turns out this wasn't an issue with a BOM. I had some newlines after the php close marker "?>". – chrislebaron Mar 23 '17 at 20:36

1 Answers1

1

I faced the same issue, but because I closed my PHP file with "?>" and added some blank lines after. After removing the "?>", problem has been solved.

In this case nothing related to BOM directly (I was in UTF-8).

If this can help other people who find this post with the same issue than me.

See post : php: empty line from nowhere

Community
  • 1
  • 1
  • You deserve a medal! I had actually given up on this because I had other things to do that were more important. I just did a simple regex search in my project for \?>\n and removed a couple of newlines after the ?> in the resulting file. Thanks a million! – chrislebaron Mar 23 '17 at 20:33