jb1990 jb1990 - 1 year ago 94
PHP Question

Netbeans issue: No new lines with PHP

I've started learning PHP and I've been using the Netbeans IDE.

I've been having an issue with Netbeans when I try to echo exact multiline text, as it is just coming out on one line.

I've tried \n, \r, and <<<_END ... _END; but the text still comes out on one line so I think it's an issue with Netbeans itself. Any help would be appreciated.

Answer Source

This has nothing to do with your editor. If you view the output in a browser, it is correct that no line break will be visible by using \n or \r\n. The browser renders HTML and so you only see a new line if you echo a <br> (the HTML tag for linebreak). However If you view the source of your generated HTML in your browser you should see a line break for \r\n.

Another way to display \r\n line breaks in your browser is to use <pre></pre>. E.g.

echo "<pre>";
echo "line 1 \r\n";
echo "line 2 \r\n";
echo "</pre>";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download