Heredoc and Nowdoc
Many times using PHP nowdoc HereDoc inserting a lot of HMTL did not succeed, the same hint of grammar problems, in fact, the PHP manual is written in this way, it is very strange
Finally found the problem, originally this kind of document at the end, must be close to the first bit of the line, that is, EOF front can not have spaces, and for the code indentation, just produced such a problem.
Copy the code code as follows:
$str = <<< ' EOD '
Example of String
Spanning multiple lines
Using Nowdoc syntax.
Eod;//eod must be close to the front, must not have spaces, and do not miss the Terminator semicolon, and this end of the EOD do not add any symbols, whether it is Heredoc or Nowdoc
attached: The difference between Heredoc and Nowdoc
Heredoc uses <<< EOT identifiers, and Nowdoc uses identifiers such as <<< ' EOT ', Nowdoc is a new technology introduced by PHP5.3, it contains heredoc syntax, but the content of which is absolutely no escape and interpretation, what content is what content, will not parse PHP related content
PHP variables in Heredoc are recommended to be enclosed in {$name->change ()} braces, which avoids some ambiguity, and if you want to use the legendary escape character \, the escape character itself can be output using an escape character, that is, the representation method, These need to be escaped out of the curly braces.
To ensure that it is indeed available, it is recommended to use Heredoc syntax, which itself is also escaped, because PHP5.3 introduced the Nowdoc syntax, many cloud hosting bad environment will probably not support the cause of the rest of the dish.
Finally, Heredoc is introduced from PHP4.0, and Nowdoc syntax requires 5.3, because Heredoc contains nowdoc functionality, so it is better to use Heredoc for personal advice.
In simple terms:
1, Heredoc is dynamic nowdoc is static
2, heredoc similar to multiple lines of double quotes newdoc similar to multiple lines of single quotation marks
3, Heredoc is a kind of general processing scheme that deals with large-segment string, and Nowdoc is the "high-efficiency" static version of PHP to make up the efficiency problem of "heredoc" in the dynamic implementation.
Heredoc and Nowdoc