new to PHP. Just having some frustrating problems with heredoc, despite following the book to the letter on syntax. The below text isn't indented as it should be.
<?php
$text="Mike's";
echo <<<_END
<!--END is just like double quoteing a var..
You can use single/double quotes without having to escape them first; inside
END. The last _END tag, has to be on the start of new line with nothing allowed
to procede it, not even whitespace-->
This is the $text 'first line'.
This is the $text 'second line'.
This is the $text 'third line'.
_END;
?>
Based on the presence of "<!--" - you are creating a html page.
You're looking at the wrong problem, heredocs don't modify whitespace - but html ignores it unless you specify otherwise. To confirm just look at the page source, it'll be what you are expecting.
If you want whitespace to be preserved - use a <pre> tag or more correctly use real markup
i.e.
<pre>
This
is
3 lines
<pre>
or
This<br>
is<br>
3 lines<br>
or
<p>This<p>
<p>is</p>
<p>3 line</p>
will all render on 3 lines.