The third method to delimit a string is using the heredoc syntax: <<<. After this operator an indentifier is provided, then a newline. The string itself follows, and then the same identifier again to close the quotation. The identifier name is chosen randomly. Such method is useful when we deal with long strings with line breaks and quote marks of different sorts.
<?php $str = <<<EOT An example of a string that stretches to several lines, using the heredoc syntax. This way you don't need to escape single ' and double " quotes EOT; print_r($str);
An example of a string that stretches to several lines, using the heredoc syntax. This way you don't need to escape single ' and double " quotes
Note that there must be no whitespaces before the closing identifier (in this case ‘EOT’). Otherwise the code execution will exit with a syntax error.
Assign the text below to the variable
$str. Use the heredoc syntax.
Lannister, Targaryen, Baratheon, Stark, Tyrell... they're all just spokes on a wheel. This one's on top, then that one's on top, and on and on it spins, crushing those on the ground.
Please sign in with your GitHub account, this is necessary to track the progress of the lessons. If you do not have an account yet, now is the time to create an account on Github.