php image display problem

Status
Not open for further replies.

david4ie

New Member
Hey

I was wondering if anybody knows how to display an image based on the url of a website. I have one website running on two different domain names and I would like the logo to change bases on the url.

This is what ive got but it doesn't seem to work:
PHP:
<?php
$url = $_SERVER['HTTP_HOST']
if ( $url = 'www.example.com') 
{
echo   "<a href=\"/\"><img src=\"img/logo.gif\" border=0></a>";
}
else if ( $url = 'www.example2.com' )
{
echo "<a href=\"/\"><img src=\"img/logo2.gif\" border=0></a>";
}
?>
Thanks
 

niall

New Member
PHP:
<?php
if ( $url = 'www.example.com') 
?>
= on it's own isn't a comparison operator. You need == :)

This is the one that has bitten everyone on the ass at some stage.
 

louie

New Member
First you shouldn't do that for SEO purposes, duplicate content but anyhow there is something I use to do in the past.
saved images (logo) as domain.ie and domain.com then used php to set the path.
PHP:
<img src='images/".str_replace("www.","",$_SERVER['HTTP_HOST']).".gif' alt='' />
 
Status
Not open for further replies.
Top