Line break using php

Is there much difference in implementing < br> and \n at the end of an indicate statement.

The simplest way to explain it truly is to test the item out.

Run this test… telephone this " experiment. php"…

PHP:


< php
echo  "< div  id='test'> this  is  a  test< /div> \n";
echo 
"< div  id='test'> this  is  a  test< /div> \n";
echo 
"< div  id='test'> this  is  a  test< /div> \n";

echo  "< div  id='test'> this  is  a  test< /div> < br> ";
echo 
"< div  id='test'> this  is  a  test< /div> < br> ";
echo 
"< div  id='test'> this  is  a  test< /div> < br> ";
>


Now view this HTML source (on your browser) in the resulting script:

< div id=’test’> that is the test< /div>
< div id=’test’> that is the test< /div>
< div id=’test’> that is the test< /div>
< div id=’test’> that is the test< /div> < br> < div id=’test’> that is the test< /div> < br> < div id=’test’> that is the test< /div> < br>

The \n is often a " literal" linefeed for any actual HTML, also it reflects that inside the output.
That < br> outputs the linefeed to the browser, but there is no " literal" linefeed within HTML.

In addition to likewise, this…
echo " < div id=’test’> that is the test< /div> \n";
echo " < div id=’test’> that is the test< /div> \n";
echo " < div id=’test’> that is the test< /div> \n";

Can do the same point as this…
echo "
< div id=’test’> that is the test< /div>
< div id=’test’> that is the test< /div>
< div id=’test’> that is the test< /div>
";

Seems a little useless to me. The \n which is.

Glenn,
You should have to remember that though, because you will note it used whenever sending
data into a functions, not much with " echo".

Example
To send headers having PHP mail(), you’ll need to use it:
From: joeaol. com\r\n Reply-To: jimcomcast. net\r\n

\r = return
\n= up coming line (new line)

return How much does that do

Most are carry-overs from the actual olden-days…
http: //www. cre8asiteforums. com/forums/index. phpshowtopic=43934

I just use them any time I’m told in order to… not knowing why, other than, " you might have to".

makes a line separate in outputted text.
makes as text.

Line breaks are useful in order to echo more than one distinct text in any div, say you’re outputting a comment such as the one below:

< php
if (strpos($_SERVER‘HTTP_USER_AGENT’, ‘MSIE’)! == FALSE)
reveal ‘You are using Internet Explorer. \nYou must try Chrome on the other hand. \nIt is often a better browser. ‘;
>

.

This entry was posted in Web Design and tagged , , , , , , , , . Bookmark the permalink.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *