How to get server address using php

Reply

Join Date: Jul 2006
Posts: 197
Reputation: vssp has a little shameless behaviour in the past 
Solved Threads: 5
vssp vssp is offline Offline
Junior Poster

How to get server address using php

 
0
  #1
Mar 30th, 2007
hi friends

I have run the one php script live server(www.live.com/samplee.php) . this file access the staging server and run the staging server php file and display the result.

But I need the live server address server name also display in the staging serevr php page result page.

How can i get the live server address?

Please help me
Thanks
VSSP
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 355
Reputation: DanceInstructor is an unknown quantity at this point 
Solved Threads: 14
DanceInstructor's Avatar
DanceInstructor DanceInstructor is offline Offline
Posting Whiz

Re: How to get server address using php

 
0
  #2
Mar 30th, 2007
[PHP]echo $_SERVER['HTTP_HOST'];[/PHP]
Last edited by DanceInstructor; Mar 30th, 2007 at 4:40 am.
Clear Mind Hosting and Web Design

If I've helped you please consider adding to my reputation.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 197
Reputation: vssp has a little shameless behaviour in the past 
Solved Threads: 5
vssp vssp is offline Offline
Junior Poster

Re: How to get server address using php

 
0
  #3
Mar 30th, 2007
hi Friend
Thanks for your quick replay.

This code get the staging server ip address but I need Live server address

Please advice
Thanks
VSSP
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 355
Reputation: DanceInstructor is an unknown quantity at this point 
Solved Threads: 14
DanceInstructor's Avatar
DanceInstructor DanceInstructor is offline Offline
Posting Whiz

Re: How to get server address using php

 
0
  #4
Mar 30th, 2007
That code should not give you an ip address, unless the server isnt setup with a host name. I dont understand your problem if you are calling a page on another server you already know the other server's host name...
Clear Mind Hosting and Web Design

If I've helped you please consider adding to my reputation.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 1,076
Reputation: Shanti Chepuru is on a distinguished road 
Solved Threads: 98
Shanti Chepuru's Avatar
Shanti Chepuru Shanti Chepuru is offline Offline
Veteran Poster

Re: How to get server address using php

 
0
  #5
Sep 25th, 2008
try this:
  1. <?
  2. $address = getenv("REMOTE_ADDR");
  3. echo $address;
  4. // Or simply use a Superglobal ($_SERVER or $_ENV)
  5. $ip = $_SERVER['REMOTE_ADDR'];
  6. ?>
The function 'getenv' does not work if your Server API is ASAPI (IIS).
So, try to don't use getenv('REMOTE_ADDR'), but $_SERVER["REMOTE_ADDR"].
Last edited by Shanti Chepuru; Sep 25th, 2008 at 3:19 am.
Be intelligent, But Don't try to cheat.. Be innocent But Don't get cheated..
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 197
Reputation: vssp has a little shameless behaviour in the past 
Solved Threads: 5
vssp vssp is offline Offline
Junior Poster

Re: How to get server address using php

 
0
  #6
Sep 25th, 2008
Thanks for your reply
Thanks
VSSP
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 20869 | Replies: 5
Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC