If anyone can help, I'm using an include to reference variables I created for some images. I'm a little unsure how to get the syntax right. The program blows up with this code.
This is my config.php file
This is the code where I'm trying to include it:Code:<?php
$logo = "images/logo.gif";
$side_logo = "images/side-logo.gif";
$s_logo = "images/s-logo.gif";
?>
If someone could show me how to properly do this I would appreciate it.Code:public function
DisplayButton($width,$name,$url,$active = true)
{
include "config.php";
echo "if ($active) {
echo "<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 {
echo "<td width=\"$width%\">
<img src=\"$side-logo\">
<span class=\"menu\">"$name"</span>
</td>";
}
}
Maybe something like that ?Code:public function DisplayButton($width, $name, $url, $active = true) {
if($active == true) {
echo "<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 {
echo "<td width='".$width."%'>"
."<img src='".$side_logo."' /><span class='menu'>".$name."</span>"
."</td>";
}
}
Jaan,
I tried your code but still no luck getting it to work. Thanks for trying. If you have any further suggestions I'm open. I'm lost with this stuff.
My instructor said that the dots on either side of the variable wern't needed for concatenating. I don't understand it enough to know why?, but it works. This section is working for me though.
I was confused with the additional styles in the section of code I asked about. Does this code make sense? I tried to apply this method to the code I asked about but I'm still confused. If you can see my errors please point them out?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>";
}
Some progress, I've got it now so the program doesn't blow up but the images still aren't coming through.
This is what I have:
Can anyone see what is causing the problem?Code:public function
DisplayButton($width,$name,$url,$active = true)
{
include ("config.php");
if ($active) {
echo "<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 {
echo "<td width=\"".$width."%\">
<img src=\"$side-logo\">
<span class=\"menu\">".$name."</span>
</td>";
}
}
Ok it's resoloved, another dumb error, image names were s-logo, side-logo, the variable names were $s_logo and $side_logo. I mis-named variables $s-logo & $side-logo in the code. Thanks for taking a look at it.
your problem with the concatenations (.) is that you have used a string that covers many lines,
and Jaan used one string per row and concatenated them instead, and he probably did that
because of readability.
Your version uses variable parsing within the strings, Jaan choose to not parse them inside the
string, probably also by readability. Neither way is wrong, it's just two versions of the same thing
what you choose is up to your personal style, or, if you are cooperating with others in larger projects,
what the project you are working in has decided to use.
to use as code style.
__________________________________________
I study Information Systems at Karlstad University when I'm not on CodeCall
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks