Heredoc/Nowdoc: Echo EOT Hello World. Goodbye! Eot // Output:-// Hello World. // Goodbye!
Heredoc/Nowdoc: Echo EOT Hello World. Goodbye! Eot // Output:-// Hello World. // Goodbye!
Heredoc/Nowdoc
So what about the heredoc and nowdoc syntaxes? They provide an alternative way of
defining strings in PHP. They are particularly useful when we need to define a string over
multiple lines.
They work by defining an identifier that will mark the start and end of the string. The
identifier can be any alphanumeric value following the same rules we’d use for variable
names. One important thing to note with the identifier is that as of PHP 7.3 you need to make
sure that it does not appear within the string itself.
echo <<<EOT
Hello World.
Goodbye!
EOT;
// Output:-
// Hello World.
// Goodbye!
C. strip
D. trim