Page 1 of 1
\n problem
Posted: Wed Apr 02, 2003 4:44 pm
by shining
First of all please excuse my poor English...
My problem is this:
Code: Select all
echo "This is line1\n This is line 2";
just prints
This is line1 This is line 2 (on the same row). Why?
Thanks
Posted: Wed Apr 02, 2003 5:25 pm
by volka
you're creating a html-document, aren't you?
try
Code: Select all
<html><body>
<p>
<?php echo "This is line1\n This is line 2"; ?>
</p>
<p>
<?php echo "This is line1<br />\nThis is line 2"; ?>
</p>
<pre>
<?php echo "This is line1\nThis is line 2"; ?>
</pre>
</body></html>
or without php
Code: Select all
<html><body>
<p>
This is line1
This is line 2
</p>
<p>
This is line1 <br />
This is line 2
</p>
<pre>
This is line1
This is line 2
</pre>
</body></html>
Posted: Thu Apr 03, 2003 1:19 am
by twigletmac
Depending on what you're doing (if you're formatting the source code then ignore me and go back to volka's post), if you're trying to format the display then you may need nl2br():
http://www.php.net/manual/en/function.nl2br.php
Mac
Posted: Thu Apr 03, 2003 3:10 am
by shining
Thanks you for the answers and once again, please excuse my poor english. I'll be back... after I will learn to write in english
