I dont understan how to echo a mix of HTML and PHP
Posted: Thu Aug 25, 2011 9:26 am
I have the following in a site
I want to be able to alternately load a GIF in place of a PNG using if@file_exists
something like
I think I am not getting all the quotes in place and think I need to use "\" but have tried various combinations to no avail. I know the above example is wrong but hopefully it gets the idea across
Any help appreciated.
Thanks
Mark
Code: Select all
<img src="/buttons/<? echo 0; ?>/ad<? echo $linenum; ?>.png" alt="<?php echo $alttxt; ?>" border="0">
I want to be able to alternately load a GIF in place of a PNG using if@file_exists
something like
Code: Select all
<?php
if(@file_exists('/buttons/0/ad'.$linenum.'.png'))
{
echo "<img src='/buttons/0/ad'.$linenum.'.png' alt=".$alttxt " border="0">";
}
else
{
echo "<img src='/buttons/0/ad'.$linenum.'.gif' alt=".$alttxt " border="0">";
}
?>
Any help appreciated.
Thanks
Mark