The HEREDOC structure is like a double-quote string that does not use double quotes, which means that single quotes are not escaped in the Heredoc structure. The variables in their structure will be replaced, but be careful when they contain complex variables in the HEREDOC structure. It is useful for formatting output content. Specifically, it has the following characteristics:
1, opening and closing tags use the same string, usually written in uppercase letters.
2. No spaces or extra characters can appear after the start tag.
3. The closing tag must be written on the head, not indented and blank, and there should be a semicolon at the end of the tag.
4. Variables located between the opening and closing tags can be parsed normally, but the function is not allowed. In Heredoc, a variable does not need a connector. Or, to splice.
The NOWDOC structure is added in PHP 5.3.0 and later versions, with the same usage and heredoc, unlike the NOWDOC structure, which is similar to the single-quote string. Parse operation is not performed in Nowdoc. This structure is ideal for embedding PHP code or other large pieces of text without escaping special characters. The structure of SGML is used to declare a large segment of text that is not parsed, and the NOWDOC structure has the same characteristics.
A NOWDOC structure is also marked with the same <<< as the HEREDOCS structure, but the following identifiers are enclosed in single quotes, i.e. <<< ' EOT '.
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.