For example:
$sql = <<<MySQL_QUERY
This operator allows for simpler three-way comparison between left-hand and right-hand operands. The operator results in an integer expression of: 0 when both operands are equal. Less than 0 when the left-hand operand is less than the right-hand operand.
The $x (single dollar) is the normal variable with the name x that stores any value like string, integer, float, etc. The $$x (double dollar) is a reference variable that stores the value which can be accessed by using the $ symbol before the $x value. These are called variable variables in PHP.
Heredoc and Nowdoc are two methods for defining a string. A third and fourth way to delimit strings are the Heredoc and Nowdoc; Heredoc processes $variable and special character but Nowdoc does not processes a variable and special characters.
That's heredoc syntax. You start a heredoc string by putting <<<
plus a token of your choice, and terminate it by putting only the token (and nothing else!) on a new line. As a convenience, there is one exception: you are allowed to add a single semicolon after the end delimiter.
Example:
echo <<<HEREDOC This is a heredoc string. Newlines and everything else is preserved. HEREDOC;
It is the start of a string that uses the HEREDOC syntax.
A third way to delimit strings is the heredoc syntax: <<<.
After this operator, an identifier is provided, then a newline. The string itself follows, and then the same identifier again to close the quotation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With