The nowdoc string creation method is similar to the heredoc method but the fact is that it works the way in single quotes as well. No parsing takes place inside the nowdoc.
Nowdoc statement starts with “<<<” sequence with their identifier but the identifier enclosed with single quotes (‘’).
Example for nowdoc php tutorials Syntax :
php 7 Sample Code : sample php program
php program Code Explanation :
In this Example “$var1” is a variable which starts with “$” dollar sign . Here the variable holds the integer value as “10”.
In this Example the nowdoc string will be defined in the echo statement and it starts with “<<<” symbol with user defined name here “Sample” is define as the user defined name for nowdoc statement and since we call the value of $var which will not display the value.
Inside the echo statement we specified multiple text strings which will be displayed in the browser as shown in the output.
nowdoc statement is ended by the same user defined name with semicolon (;).
php coding Sample Output :
variable name “$var” defines the string as nowdoc so the output will be displayed whose value will not be assigned for the variable “$var” apart from this, the newline spaces will also be removed as shown above.