when a carriage return follows a closing php tag, php doesn't print it.
How can I change this?
Thanks a lot
when a carriage return follows a closing php tag, php doesn't print it.
How can I change this?
Thanks a lot
That's normal behavior, and cannot be changed : the newline after a closing ?>
is always ignored.
Here's the reference, in the FAQ of the PHP manual : Hey, what happened to my newlines?
(quoting, emphasis mine)
<pre>
<?php echo "This should be the first line."; ?>
<?php echo "This should show up after the new line above."; ?>
</pre>
In PHP, the ending for a block of code is either "
?>
" or "?>
" (wheremeans a newline).
So in the example above, the echoed sentences will be on one line, because PHP omits the newlines after the block ending.
This means that you need to insert an extra newline after each block of PHP code to make it print out one newline.
Why does PHP do this?
Because when formatting normal HTML, this usually makes your life easier because you don't want that newline, but you'd have to create extremely long lines or otherwise make the raw page source unreadable to achieve that effect.
And here are a couple of interesting reads about this :