[prev] [index] [next]

Strings (cont)

Strings (cont)

"heredoc" strings available for large multi-line strings

print <<<XYZ
This is a "here" document. It can contain
many lines of text, with interpolation.
Such as the value of x is $x
With any old "quotes' the we ``like''
XYZ;

$str = <<<aLongString
This is my "long" string.
Ok, it's not really so long\n
aLongString;

Note: no newline at end of last line, unless via explicit \n.