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
|