Re: no newline after "?>" in the resulting HTML
| From: | Richard Lynch | Date: | Mon, 20 Mar 2006 23:51:32 +0000 |
| Subject: | Re: no newline after "?>" in the resulting HTML | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-232274@lists.php.net to get a copy of this message | ||
On Sat, March 18, 2006 12:36 pm, Rostislav Krasny wrote:
> <p>Hello World</p>
> </body>
> <p>Hello World</p></body>
> Why there is no newline afer " <p>Hello World</p>" ?
> Is it a PHP bug or the tutorial should be updated?
The tutorial is imprecise, and glosses over this detail.
For very good reasons, ?>[newline] ignores the trailing [newline]
character.
If you want the newline, you should do:
<?php
echo "<p>Hello World</p>\n";
?>
As for WHY the [newline] after ?> is ignored, it just turns out that
there are more times when you want it that way than the other, *AND*
it's trivial to insert a \n into your output, *AND* it would be very
hard to come up with a way to make the newline NOT appear if the
default was to have it appear, *AND* a *TON* of things would go wrong
if the extra newline appeared where you don't want it, but it's pretty
unimportant if a newline is missing at that point in the tutorial and
in most real-world cases (IE, HTML output) where you have ?>[newline]
It's not a bug ; It's a feature
--
Like Music?
http://l-i-e.com/artists.htm