Re: Question about new lines [message #175497 is a reply to message #175489] |
Sun, 02 October 2011 21:52 |
Thomas Mlynarczyk
Messages: 131 Registered: September 2010
Karma:
|
Senior Member |
|
|
Linus Flustillbe schrieb:
> -------------------------
> <html>
> <body>
> <?php
> $d=date("D");
> if ($d=="Fri")
> echo "Have a nice weekend!";
> elseif ($d=="Sun")
> echo "Have a nice Sunday!";
> else echo "Have a nice day!";
> echo "\nhello boss"."\t"."does this work".PHP_EOL;
> echo "again";
> ?>
> </body>
> </html>
> ---------------------------------
> When I load this in my browser I see the following
> ------------------------
> Have a nice Sunday! hello boss does this work again
As was to be expected on a Sunday.
> -------------------------
> And if I look at the page source (using Firefox)
> --------------------------
> <html>
> <body>
> Have a nice Sunday!
> hello boss does this work
> again</body>
> </html>
> ------------------------
As was to be expected on a Sunday.
> Should the "\n" not push a NewLine out to the output?
Well it does, doesn't it? Without the "\n" and the PHP_EOL your source
would look like this:
> Have a nice Sunday!hello boss does this workagain
The output of PHP is the HTML source code. How the browser renders that
is another matter. If you want the line breaks to appear in the
browser's output, do as the other posts suggest.
Greetings,
Thomas
--
Ce n'est pas parce qu'ils sont nombreux à avoir tort qu'ils ont raison!
(Coluche)
|
|
|