Reputation: 34585
I am generating a large amount of HTML code with PHP using echo
and it is all appearing on one line.
I understand that HTML ignores whitespace, and there are thousands of answers which point out that you need <BR>
or a block element. But that is not my question.
My problem is that is very hard to debug my HTML source code when it is all on one line. I am using Windows 7 and the Firefox browser tool Page Source to show the source code.
For a simple example, if the text editor I use shows
<HTML><BODY>
Hello, World!
</BODY></HTML>
Then the browser source code tool shows exactly that too, and when I generate it with PHP like
<?php
echo "<HTML><BODY>";
echo "Hello, World!";
echo "</BODY></HTML>";
?>
then the browser tool shows, as you would expect,
<HTML><BODY>Hello, World!</BODY></HTML>
I want to break the lines, and have tried
<?php
echo "<HTML><BODY>\n";
echo "Hello, World!\n";
echo "</BODY></HTML>\n";
?>
and with "\r\n"
and with "\xA"
and also like this
<?php
echo "<HTML><BODY>" . PHP_EOL;
echo "Hello, World!" . PHP_EOL;
echo "</BODY></HTML>" . PHP_EOL;
?>
yet the content stays resolutely on a single line.
Upvotes: 0
Views: 190
Reputation: 532
This works on windows
<?php
echo "<HTML><BODY>
";
echo "Hello, World!
";
echo "</BODY></HTML>
";
?>
Upvotes: 1