The HEREDOC structure resembles a double-quote string, and the Nowdoc structure is similar to a single-quote string. The NOWDOC structure is much like the heredoc structure, but Nowdoc does not perform parsing operations. This structure is well suited for use in PHP code and other large pieces of text that do not need to be escaped. And the <! of SGML [cdata[]]> structure is used to declare a large segment of the text like no parsing, nowdoc structure has the same characteristics.
A NOWDOC structure is also labeled <<< with the same heredocs structure, but the following markers are enclosed in single quotes, like the <<< ' EOT '. All rules of the HEREDOCS structure also apply to the NOWDOC structure, especially the rule of the end marker.
Take a look at the following examples of Heredoc:
$name= "Jbilder"; $age= "18"; $title= "jbilder_9986"; Echo "Here is the use of Heredoc: <br/>"; echo <<<jbilderphp How to solve the session when the custom session is covered??? My nameis: {$name}; Age: {$age}; Title: {$title}. jbilderphp;
The resulting results are:
Take a look at the following examples of Nowdoc:
1 $name= "Jbilder"; $age= "18"; $title= "jbilder_9986"; 2 Echo "Here is the use of Heredoc: <br/>"; 3 echo <<<jbilderphp4 How to fix the session when the custom session is covered??? My name is: {$name}; Age: {$age}; Title: {$title}. 5 jbilderphp;
View Code
The resulting results are:
Note that for Heredoc variables to be enclosed in curly braces, if you write directly as follows:
1 echo <<< ' jbilderphp '2 How to fix the session when a custom session is covered??? My name is:$name; Age:$age; title:$title. 3 jbilderphp;
View Code
You will receive the following prompt error:
What are the Heredoc and Nowdoc in PHP