Originally posted by ShawnD
that EOP thing is pretty cool, are there any catches to it? like does it cause problem when situation?
$var = <<<EOF
This is a paragraph of text. I can do $variable interpolation, and I don't have to worry about "escaping" and such.
EOF;
The syntax begins with "<<<" followed by some string that you're going to use as a delimiter. EOF is traditional, but other words can be used - vital when the text you're trying to say contains a line that starts with "EOF"! I just used "EOP" 'cos it was short for "End Of Paragraph".
The string itself begins at the first character of the next line (in this example, that's the 'T').
It continues until the last character before your chosen delimiter string (in this example, that's a '.'.)
The closing delimiter string must be at the very start of its line (no indentation or any other whitespace). Basically, apart from the semicolon, the closing delimiter string is all that should be on that line.
The carriage returns immediately after the first delimiter string and immediately before the second are ignored:
$string = <<<EOW
sentence
EOW;
echo "This is a $string.";
outputs "This is a sentence.".
This apparently can cause problems in some Windows-based editors, because of its braindead way of handling linebreaks; but any decent Windows text editor will allow you to save files using Unix linebreak conventions (i.e., using "\n" instead of "\r\n" - it's the rogue "\r" that throws PHP off in this situation).
The server problem mentioned by ShawnD is more a matter of the fact that some hosts are still running old versions of PHP that don't support this syntax. If you're DIYing it, you should be fine.