bradgrafelman;10988575 wrote:I always advise against using the '<?' (and '<?=(expresssion)?>') shot-open tags, since they can be disabled (and often are).
Why are you storing a bunch of data in a variable $html, only to immediately output it later? Why not just output the data right away?
There's no need to heavily over-complicate the code by defining $html line-by-line. You can easily just do:
$var = "This variable assignment contains multiple lines.
In fact, as many lines as I want!
Notice how I don't have to type out '$var .=' approximately 99999 times? ;)
";
or even:
$var = <<<EOD
Here's yet another multi-line value being assigned to a variable.
This time, however, you don't even have to worry about the "quotes" used, since we're using the heredoc syntax.
EOD;
Next, if the data doesn't contain any PHP variables or anything like that (e.g. it's just static data), why waste the time of involving PHP at all? Simply escape out of PHP mode and just output the HTML directly...
<?php
$foo = 'bar';
// And now for some static HTML:
?><html>
<head>
<title>Code :: Simplified</title>
</head>
....
<?php
echo $foo;
?>
Finally, note that the build_gallery function [man]return[/man]s a value, and yet you never do anything with that return value. In other words, you might as well not even call that function.
I suspect, however, you wanted to either output that returned value or include it in the $html variable (a variable which should just be eliminated completely, IMHO).
I had this code first, but it didnt work either
<style type="text/css">
.maincontainer
{
width: 100%;
clear: both;
}
.itemcontainer
{
width: 160px;
height: 150px;
float: left;
padding: 5px;
margin: 0px;
border-style: solid;
border-width: 1px;
}
.itemcontents
{
font-style: center;
}
.itemimagesize
{
width: 160px;
height: 120px;
}
</style>
<?php
function build_gallery($spnName,$snpImgSrc,$spnImgAlt,$splLink,$splGallery,$splCaption,$splImgSrc,$splImgAlt,$splImgWidth,$splImgHeight,$splTitle) {
$gallery = "{simplepopup name=\"$spnName\" popup=\"false\"} <img src=\"$spnImgSrc\" alt=\"$spnImgAlt\"> {/simplepopup} {simplepopup link=\"$splLink\" gallery=\"$splGallery\" hidden=\"true\" Title=\"$splCaption\"} <img src=\"$splImgSrc\" alt=\"$splImgAlt\" width="$splImgWidth" height="$splImgHeight"> $splTitle {/simplepopup}";
return $gallery;
}
?>
<div class="maincontainer">
<div class="itemcontainer">
<div class="itemcontents">
{simplepopup name="FordThunderbird1" popup="false"}
<img src="/InstallationGallery/FordThunderbird/IMG_0019.png" alt="TB1">
{/simplepopup}
{simplepopup link="FordThunderbird1" gallery="FordThunderbird" hidden="false" Title="Insert a Caption"}
<img src="/images/InstallationGallery/FordThunderbird/IMG_0019.png" alt="TB1" width=160 height=120>
Ford Thunderbolt
{/simplepopup}
<?php build_gallery("FordThunderbird1","/InstallationGallery/FordThunderbird/IMG_0019.png","TB1","FordThunderbird1","FordThunderbird","Insert a Caption","/images/InstallationGallery/FordThunderbird/IMG_0019.png","TB1","160","120","PopUp Image"); ?>
<?php build_gallery("FordThunderbird2","/InstallationGallery/FordThunderbird/IMG_0004.png","TB2","FordThunderbird2","FordThunderbird","Insert a Caption","/images/InstallationGallery/FordThunderbird/IMG_0004.png","TB2","160","120","PopUp Image2"); ?>
<?php build_gallery("FordThunderbird3","/InstallationGallery/FordThunderbird/IMG_0005.png","TB3","FordThunderbird3","FordThunderbird","Insert a Caption","/images/InstallationGallery/FordThunderbird/IMG_0005.png","TB3","160","120","PopUp Image2"); ?>
</div>
</div>
</div>