Constant
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.
Here’s an example of a heredoc.
echo <<<EOT
Hello World.
Goodbye!
EOT;
// Output:-
// Hello World.
// Goodbye!
28. What is PHP heredoc used for?
A. allows creating single line of string without using quotations
B. allows creating multiple lines of string without using quotations
C. allows creating multiple lines of string with quotations
D. allows creating single lines of string with using quotations
Which function is used to Strip whitespace (or other characters) from the beginning and end
of a string?
A. trim_str
B. strip_str
C. strip
D. trim