Another should-know-this-already snippet of PHP know-how…

PHP will not include any line breaks immediately after a closing PHP tag. If you need or want to preserve white space in your rendered HTML code you’ll need to add a space in between the closing tag and the line break – or add echo "\n" ;.

Line break after the a closing PHP tag is removed:

php-linebreak-not-working

If you add a space after the closing PHP tag the line break is preserved:

php-linebreak-preserved

Last Updated on