Heredoc

Heredoc is a robust way to create string in PHP with more lines but without using quotations. Heredoc is rarely used as the day by day usage is more complicated as creating strings with quotes or double quotes. Besides this the not properly used heredoc can lead to problems in your code.

 

Example

<?php
$str = <<<DEMO
phpcode
DEMO;
print $str;
?>

Output

phpcode

Share