Heredoc
A string expressed with heredoc is interpreted just as in double quotes. The difference here is that you won’t have to escape any double quote characters in the string. This is handy when assigning large blocks of text which contain either a mixture of single and double quotes, and/or a mixture of double quotes and variables.
The “opening quote” as it were is triple less than symbols followed by an identifier. This identifier can be almost anything. It only has to follow the same naming conventions as a variable in PHP (must contain only alphanumeric or underscores, and must not begin with a digit). Follow that with a new line and the string begins.
The “closing quote” here is a new line, that same identifier, a semicolon, and a new line. That is, the identifier and semicolon on its own line without any other characters (including whitespace) on that line.
$var = "monkeys"; $text = <<<EndStr My text goes here. It can have "quotes" of 'all types'. It can also have $var and \n\nspecial characters. EndStr; /* My text goes here. It can have "quotes" of 'all types'. It can also have monkeys and special characters. */
Just remember the triple less than symbols as pointing the way. They squeeze the text into the variable or echo statement. Most importantly, remember that the closing identifier must have no other characters on the line with it. Even tabs are not allowed. It may mess up your indentation but that’s the rule.
