Both these inputs get outputted as a single line.
I'm doing it just as my book shows. According to my book, these formats should respect all the whitespace and linebreaks without having to do the \n crap.
<?php
$author = "Alfred E Newman";
echo <<<_END
This is a Headline
This is the first line.
This is the second.
- Written by $author.
_END;
?>
<?php
$author = "Alfred E Newman";
$text = "This is a Headline
This is the first line.
This is the second.
Written by $author.";
echo $text
?>
EDIT here' i'll quote my book on what it says this block of code should do " PHP also offers a multiline sequence using the <<< operator, commonly referred to as a here-doccument or heredoc for short. This is a way of specifying a string literal, preserving the line breaks and other whitespace (including indentation) in the text. Its use can be seen in Example 3-8." Eg.3-8 would be the first piece of code I posted on here. The book I'm using is, "Learning PHP, MySQL, JavaScript, and CSS" by Robin Nixon
ANOTHER EDIT Okay this is weird, I copy and pasted the Example #2 for the heredoc example on from the PHP manual into my PHP IDE and got the same result when the output should obviously be different "http://www.php.net/manual/en/language.types.string.php"
perhaps it's my IDE? I am running WAMP and everything seemed to be running fine until now...
EDIT AGAIN zomfg i hate when this happens, later on in the book he says it's normal because HTML formatting rules take over and white space is supprpessed" My bad guys. TBH, I don't see the point of it being only visible in the source page but not being formatted with the new lines. What good use is that when you can just open the original file and see it for yourself with the
instead of newline chars – bumperbox Mar 31 '14 at 01:40