Newbee question

  • Thread starter Thread starter Anonymous
  • Start date Start date
A

Anonymous

Guest
Hi

Hope some one can shed some light on a small problem I have.

I want to dynamically display a logo depending on what domain is pointing at the site.

So at the moment the code is this

define('HTTP_SERVER', 'http://www.domain.com');

I have tried this but it has thrown up errors.

define('HTTP_SERVER', '.$_SERVER['SERVER_NAME'].');

Can this be done or have I just written the code wrong

Thanks in advance :idea:
 
I have several domains mirroring a virtual server.

So depending on what domain you use to access the site it will display an appropriate logo.

The site is part of a shop, so this line is defining a variable used through out the site

define('HTTP_SERVER', 'http://www.domain.com');

This is why I want it to look at the domain and display etc etc etc ..........

So is this totally wrong or is their just a slight error in the code

define('HTTP_SERVER', '.$_SERVER['SERVER_NAME'].');
 
The variabel $_SERVER['SERVER_NAME'] refers to the servername which will be the same for each domain pointing to that server

Instead use: $_SERVER['HTTP_HOST']

So
define('HTTP_SERVER', $_SERVER['HTTP_HOST'])

should do the trick

Use the function phpinfo(); anywhere in your script to see what variables are available in your scripts and what their value is.
 
You can use $_SERVER['HTTP_HOST'], my point is I don't see why you want to define it as a constant, when it already exists in the Super Global Array!
 
Back
Top