/ Published in: PHP
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.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?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; ?>
URL: http://coboldinosaur.com/pages/Keep_it_Simple_Using_HEREDOC.html