I want to use some variables to reference images in my code. It's suppose to make the code more efficient. I'm having trouble understanding how to set it up. I have a config.php file created for the variables, like this:
I want to use these in my program code now. The original code looks like this:PHP Code:<?
$logo = <img src = images/"logo.gif" />
$side_logo = <img src= images/"side-logo.gif" />
$s_logo = <img src= images/"s-logo.gif" />
?>
To use the variables now, do I want to make it something like this?PHP Code:public function DisplayHeader()
{
<?
<table width="100%" cellpadding="12"
cellspacing="0" border="0">
<tr bgcolor ="black">
<td align ="left"><img src = "logo.gif" /></td>
<td>
<h1>TLA Consulting Pty Ltd</h1>
</td>
<td align ="right"><img src = "logo.gif" /></td>
</tr>
</table>
<?php
}
or this section;PHP Code:public function DisplayHeader()
{
include "config.php";
echo "<table width=\"100%\" cellpadding=\"12\"
cellspacing=\"0\" border=\"0\">
<tr bgcolor =\"black\">
<td align =\"left\"><img src = \"".$logo."\" /></td>
<td>
<h1>TLA Consulting Pty Ltd</h1>
</td>
<td align =\"right\"><img src = \"".$logo."\" /></td>
</tr>
</table>"
}
and replace with this code?PHP Code:public function
DisplayButton($width,$name,$url,$active = true)
{
if ($active) {
echo "<td width = \"".$width."%\">
<a href=\"".$url."\">
<img src=\"s-logo.gif\" alt=\"".$name."\" border=\"0\" /></a>
<a href=\"".$url."\"><span class=\"menu\">".$name."</span></a>
</td>";
} else {
echo "<td width=\"".$width."%\">
<img src=\"side-logo.gif\">
<span class=\"menu\">".$name."</span>
</td>";
}
}
Is this the right way to do this?PHP Code:public function
DisplayButton($width,$name,$url,$active = true)
{
include "config.php";
echo "if ($active) {
"<td width = \"".$width."%\">
<a href=\"".$url."\">
<img src =\"".$s_logo."\" alt=\"".$name."\" border=\"0\" /></a>
<a href=\"".$url."\"><span class=\"menu\">".$name."</span></a>
</td>";
} else {
"<td width=\"".$width."%\">
<img src = \"".$s_logo."\" />
<span class=\"menu\">".$name."</span>
</td>"
}
}




Reply With Quote