Re: Newlines don't work.



Vincent <newsgroup@xxxxxxxxxxxxxxx> wrote:
lister schreef:
Hi,
I am trying to output a newline, but this doesn't work:
echo "Line1\nLine2";
Before anyone says, I know HTML doesn't recognise newlines. I don't
need newlines in the rendered HTML, I need newlines in the SOURCE to
make it understandable.
Cheers,
Lister
echo("line1\n");
echo("line2");

or

<?php
$str = <<<EOD
Example of string
spanning multiple lines
using heredoc syntax.
EOD;
echo($str);
?>

While I'm a fan of heredoc, just using single quotes will also work.
--
Rik Wasmus
.



Relevant Pages

  • Re: CGI.pm and lost carriage returns
    ... input with tags instead of newlines, and nothing more: ... when displaying text in a browser. ... But the input was *NOT* meant to be HTML in the first place, ... designer wants user newlines to be retained in formatting. ...
    (comp.lang.perl.misc)
  • Re: [PHP] dont work!!!
    ... > very lousy one. ... I do want to just make a html page. ... echo "This spans ... The newlines will be\noutput as well."; ...
    (php.general)
  • Re: [PHP] dont work!!!
    ... Wang Feng wrote: ... echo ... The newlines will beoutput as ... In html you cannot use newlines for formating, ...
    (php.general)
  • Re: Reading from file
    ... But in file news.txt I have formating that is not showing, ... of HTML, it will be interpreted as HTML. ... echo ); ... Although I don't think that will deal with newlines being interpreted ...
    (comp.lang.php)
  • Re: simple jsp question (out.println)
    ... Since your subject line mentions JSP (btw, it'd be a good idea to ... The println statement is, indeed, writing newlines. ... is that they aren't significant in HTML. ... Source" from your web browser when you test the page. ...
    (comp.lang.java.help)