Re: Embedding HTML Within a PHP Statement [message #176008 is a reply to message #175980] |
Tue, 15 November 2011 02:15 |
bobmct
Messages: 16 Registered: September 2010
Karma:
|
Junior Member |
|
|
FWIW - I have to read and maintain lots of php code written by others
all day long. In my learned experience the drop in / drop out of php
again and again is a real pain on the eyes.
My preference is to output entire blocks of html code using heredocs
so the program actually never drops out of php.
Something like this snippet:
<?php
..
..
..
//*************************************************************************
// Default 'unknown' content
else {
$_HeadWords = "Uh Oh!";
$_Image = "pix/UhOh.jpg";
$_Verbiage = "Content Indicator ($func) UNDEFINED!.";
}
//*************************************************************************
// Now print the column
print <<<EOD
<div id="left-column"><!-- Begin left-column area -->
<img class="image-left" src="$_Image" height="189" width="299"
alt="$_Alt" />
<div style="margin: 10px 10px 10px 10px;"><!-- Begin inline style area
-->
<h3>$_HeadWords</h3>
<p class="align-left">$_Verbiage</p>
</div><!-- End inline style area -->
</div><!-- End left-column area -->
<div id="right-column"><!-- Begin of right-column area -->
EOD;
}
// End of _LeftColumn function
//************************************************************************* *****
..
..
..
?>
Preferences vary by individual. But something like the above will
help the "next" guy who has to work with the code.
Bob
|
|
|