$foo = 'foo';
$here = <<<HERE
I'm here, $foo!
HERE;
echo $here;
$foo = 'foo';
$now = <<<'NOW'
I'm now, $foo!
NOW;
echo $now;
$here is "I'm here, bar!", while $now is "I'm now, $foo!".
If you don't need variable interpolation but need special characters like $ inside your string, Nowdocs are easier to use. That's all.
Comments 4