FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Question about new lines
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Question about new lines [message #175492 is a reply to message #175489] Sun, 02 October 2011 15:43 Go to previous messageGo to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma:
Senior Member
On 10/2/2011 10:00 AM, Linus Flustillbe wrote:
> I come from a scripting background so am not unfamiliar
> with the concept of CR/LF characters. I am in the process
> of learning PHP via the following tutorial
>
> http://mobilitystudies.com/mob/images/stories/PHP_Tutorial_From_beginner_to _master.pdf
>
> Currently I have "hello.php" with the following lines of code
>
> -------------------------
> <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
> -------------------------
> And if I look at the page source (using Firefox)
> --------------------------
> <html>
> <body>
> Have a nice Sunday!
> hello boss does this work
> again</body>
> </html>
> ------------------------
> Should the "\n" not push a NewLine out to the output?
> I did some research and found that the PHP_EOL seems to be what is
> recommended since it is platform independant. But it doesn't work
> either.
>
> Can anyone suggest or point out what I am doing wrong, or is this a flaw
> in php?
>
> Thanks
>

The fact that it looks OK in your page source indicates this isn't a PHP
problem, but an HTML one. HTML ignores most whitespace.

Before getting into PHP too much, I would suggest you get a book on HTML
and learn more about how it works, or you'll continue to fight
"problems" like this in the future.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: comparing dates?
Next Topic: hai
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 10 05:56:39 GMT 2024

Total time taken to generate the page: 0.04334 seconds