Hereis Document for PHP: Great for Generation of HTML
November 19th, 2009
The great thing about hereis documents is that in most cases you don't have to backslash quotes, your "html" thus retains its visibility
echo <<<__HTML__
<li><a href=”$pressdir$file”>$file</a>
__HTML__;
$html.= <<<__HTML__
<li><a href=”$pressdir$file”>$file</a>
__HTML__;
return <<<__HTML__
<li><a href=”$pressdir$file”>$file</a>
__HTML__;
it can also cope with arrays if you use the following syntax ${my_array['postcode']}
return <<<__HTML__
<li><a href=”$multimap_url${my_array['postcode']}”>${my_array['postcode']}</a>
__HTML__;
I see so much ugly tangled php/javascript/html/css code which could be tidied up with the PHP Hereis Document