Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Newbee question

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Newbee question

Postby garyw74 » Thu Oct 24, 2002 5:33 am

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:
garyw74
New php-forum User
New php-forum User
 
Posts: 5
Joined: Wed Oct 09, 2002 6:22 am

Postby Jay » Thu Oct 24, 2002 6:59 am

Why on earth would you want to do that???????
Jay
 

Postby garyw74 » Thu Oct 24, 2002 7:15 am

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'].');
garyw74
New php-forum User
New php-forum User
 
Posts: 5
Joined: Wed Oct 09, 2002 6:22 am

Postby DutchBen » Thu Oct 24, 2002 10:51 am

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.
DutchBen
New php-forum User
New php-forum User
 
Posts: 36
Joined: Thu Oct 24, 2002 10:28 am
Location: Amsterdam

Postby Jay » Thu Oct 24, 2002 1:10 pm

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!
Jay
 


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron