In php, heredoc and nowdoc are two defined strings. [Php]? Php is troublesome when it needs to write a large text segment with many lines containing single quotation marks and double quotation marks, leading to escape. you can also use heredoc and nowdoc to define the string's [php]
// When you need to write a large text segment with many lines containing single quotation marks and double quotation marks, it is troublesome to escape.
// You can also use heredoc or nowdoc to define strings.
$ Age = 29;
$ Str = <
Let me write a line,
Line 2 ,'"\,
Dsafd abc \ t \ r \ n haha
$ Age
Cont;
Echo $ str;
/**
Heredoc
< <标识符 < p>
Large text in the middle
Identifier;
Note:
1: The identifier name must be the same as the variable name.
2: The identifier of heredoc. it must be an exclusive line without any other characters.
3: heredoc can parse text like double quotation marks (\ r \ n \ t), variables, and so on.
**/
// Heredoc is easy to write large text segments, but it parses internal characters like double quotation marks.
// If I don't want this, is there a large text like heredoc,
// However, parsing text is as simple as single quotes.
// Is there any such usage?
// A: www.2cto.com is available.
// After 5.3.0, the nowdoc method is added to achieve the above effect.
Echo'
';
$ Str = <'cont'
Let me write a line,
Line 2 ,'"\,
Dsafd abc \ t \ r \ n haha
$ Age
Cont;
Echo $ str;
/***
The nowdoc writing method is the same as heredoc, but the identifiers are enclosed in single quotes,
In this way, the parsing of large text is the same as that of single quotes.
Do not escape \ n \ r \ t, variables, etc.
***/
?>
Why? Php // when you need to write a large text segment with many lines containing single quotation marks and double quotation marks, it is troublesome to escape the text. // You can also use heredoc and nowdoc to define the string...