Return to Snippet

Revision: 64310
at July 23, 2013 06:07 by COBOLdinosaur


Initial Code
<?php
echo <<<'WOW'
<pre style="display:inline-block;border:2px solid blue;border-radius:8px;padding:10px;">
<form action="$formLink" method="get">
<input name="name" type="text" value="$junk" />
<aside>Now, I am printing some {$junk->stuff[1]}.<br />
This should not print a capital 'A': \x41</aside>
</pre>
WOW;
?>

Initial URL
http://coboldinosaur.com/pages/Keep_it_Simple_Using_HEREDOC.html

Initial Description
Doing the echo with multiple concatenated bits of strings was very error prone and I was always getting parsing errors. The toggle format where you flip PHP on and off throughout the HTML is less error prone but is a real pain in the ass if you have short tags disabled. Those methods are okay for short pieces of code, but any long page just can't be easily generated that way.

Initial Title
HEREDOC to Simplify Code Generation

Initial Tags
php, page

Initial Language
PHP