Write a large paragraph of text in the middle
Identifier;
Note:
1: The requirements for identifier names and variable names are the same.
2: The heredoc identifier must be on its own line and not preceded by any other characters.
3: heredoc processes text in the same way as double quotes, that is, rnt, variables, etc. can be parsed.
**/
// Heredoc is very convenient for writing large paragraphs of text, but the internal character analysis is the same as double quotes.
// If I don’t want to do this, is there any way to write large text like heredoc?
// However, parsing text is as simple as single quotes.
// Is there any such usage?
// Answer: Yes www.2cto.com
// After 5.3.0, the nowdoc method has been added, which can achieve the above effect.
echo '
';
$str = <<<'cont'
Let me write a line,
Come to line 2, ' " ,
dsafd abc t rn haha
$age
cont;
echo $str;
/***
Nowdoc is written in the same way as heredoc, except that the identifier is wrapped in single quotes,
In this way, the parsing of large text has the same effect as single quotes.
Do not escape n r t, variables, etc.
***/
?>
http://www.bkjia.com/PHPjc/477764.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/477764.htmlTechArticle[php] ?php // When you need to write a large paragraph of text, many lines, and there are single quotes in it, There are double quotes, which makes escaping more troublesome. // You can also use heredoc and nowdoc to define strings...