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 #175528 is a reply to message #175489] Tue, 04 October 2011 13:38 Go to previous message
Michael Joel is currently offline  Michael Joel
Messages: 42
Registered: October 2011
Karma:
Member
On 02 Oct 2011 14:00:27 GMT, Linus Flustillbe
<admin(at)nacs(dot)dyndns-office(dot)com> 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
> [SNIP]
> Can anyone suggest or point out what I am doing wrong, or is this a flaw
> in php?
>
> Thanks

Simple Answer:
\n is PHP for breaking a line. It is not translated as the HTML <BR>
as you (and I when I first started using PHP) had been expecting. It
will format your HTML source with new lines - without it all the
source would run together on one line.

To have the browser break a line you need to still each to the browser
an HTML line break <BR>.

So examples:
code:
echo "1, 2, 3, 4, \n5, 6, 7";

output:
1, 2, 3, 4, 5, 6, 7

source view:
1, 2, 3, 4,
5, 6, 7

--------------------------------------------
code:
echo "1, 2, 3, 4, \n<BR>5, 6, 7";

output:
1, 2, 3, 4,
5, 6, 7

source view:
1, 2, 3, 4,
<BR>5, 6, 7
--------------------------------------------

code:
echo "1, 2, 3, 4, \n<BR>\n5, 6, 7";

output:
1, 2, 3, 4,
5, 6, 7

source view:
1, 2, 3, 4,
<BR>
5, 6, 7

Hope that makes it simple and clear.
Mike
[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: Tue Nov 26 08:53:17 GMT 2024

Total time taken to generate the page: 0.04321 seconds