Line break using php

<br> is more correctly <br /> per latest HTML standards and causes a line break in the web page as presented by the browser, or when printed.

\n outputs is a new line character which is interpreted as white space and ignored by the browser, but is meaningful in text and source code files. Placing \n at the end of your echo strings will change your browser's display of source code from this:
HTML:
select name="select"><option value="A">A</option><option value="B">B</option><option value="C">C</option><option value="D">D</option></select>

to this:
HTML:
<select name="select">
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
<option value="D">D</option>
</select>

Note, I just discovered this fact: In order for \n to work, you must enclose your string to be echo'ed in double quotes, and escape double quotes that are part of the string.
 
@DesignerBill, @Glenn
I have encountered the same problem with \n. So what i do is that i enclose the <br> tag in my echo statement.
 
Top