Page 1 of 1

How do I find documentation on =<<<

Posted: Tue Mar 22, 2005 10:37 am
by neophyte
I'm trying to find documentation on php.net on "$template =<<< STOP;" but I'm not sure what to search for and I can't find it.

What do you call it?
feyd wrote:

Code: Select all

&lt;?php

$template =&lt;&lt;&lt;STOP
&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;{TITLE}&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;div style=&quote;text-align:right; border: 2px red solid; background-color: yellow; color: blue; padding: 10px 10px 10px 10px; font-weight: bold;&quote;&gt;{ERROR_DATA}&lt;/div&gt;
  &lt;/body&gt;
&lt;/html&gt;
STOP;

?&gt;

Posted: Tue Mar 22, 2005 10:40 am
by feyd
heredoc

Posted: Tue Mar 22, 2005 10:57 am
by neophyte
Thanks Feyd

Posted: Tue Mar 22, 2005 11:09 am
by anjanesh
This is interesting.
In the php manual (http://in.php.net/types.string),
$str = <<<EOD
Example of string
spanning multiple lines
using heredoc syntax.
EOD;

How is any different/better than
$str = "
Example of string
spanning multiple lines
not using heredoc syntax.";

Posted: Tue Mar 22, 2005 11:20 am
by neophyte
php manual wrote: Heredoc text behaves just like a double-quoted string, without the double-quotes. This means that you do not need to escape quotes in your here docs, but you can still use the escape codes listed above. Variables are expanded, but the same care must be taken when expressing complex variables inside a here doc as with strings.

Posted: Tue Mar 22, 2005 2:40 pm
by Ambush Commander
If you're going to still need large blocks of text hardwired into your script without variable decompression (?word choice?), you may want to consider trying to seperate this info from the script, or, if all else fails, "Output Buffering". http://us2.php.net/manual/en/function.ob-start.php You shouldn't have to have huge blocks of text in your PHP script, by structuring your code correctly, it should be able to be ported to other files or databases.