944,098 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 45758
  • PHP RSS
Mar 30th, 2007
0

How to get server address using php

Expand Post »
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
Similar Threads
Reputation Points: 5
Solved Threads: 5
Junior Poster
vssp is offline Offline
197 posts
since Jul 2006
Mar 30th, 2007
0

Re: How to get server address using php

[PHP]echo $_SERVER['HTTP_HOST'];[/PHP]
Last edited by DanceInstructor; Mar 30th, 2007 at 4:40 am.
Reputation Points: 17
Solved Threads: 14
Posting Whiz
DanceInstructor is offline Offline
355 posts
since Feb 2005
Mar 30th, 2007
0

Re: How to get server address using php

hi Friend
Thanks for your quick replay.

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

Please advice
Reputation Points: 5
Solved Threads: 5
Junior Poster
vssp is offline Offline
197 posts
since Jul 2006
Mar 30th, 2007
0

Re: How to get server address using php

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...
Reputation Points: 17
Solved Threads: 14
Posting Whiz
DanceInstructor is offline Offline
355 posts
since Feb 2005
Sep 25th, 2008
0

Re: How to get server address using php

try this:
php Syntax (Toggle Plain Text)
  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 C; Sep 25th, 2008 at 3:19 am.
Reputation Points: 137
Solved Threads: 162
Posting Virtuoso
Shanti C is offline Offline
1,641 posts
since Jul 2008
Sep 25th, 2008
0

Re: How to get server address using php

Thanks for your reply
Reputation Points: 5
Solved Threads: 5
Junior Poster
vssp is offline Offline
197 posts
since Jul 2006
Dec 20th, 2010
0
Re: How to get server address using php
PHP Syntax (Toggle Plain Text)
  1. <?php
  2.  
  3. echo "server address:".$_SERVER['SERVER_ADDR']."<br/>";
  4.  
  5. ?>
Last edited by Ezzaral; Dec 20th, 2010 at 6:01 pm. Reason: Added code tags. Please use them to format any code that you post.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
chathurika1981 is offline Offline
1 posts
since Dec 2010
Oct 2nd, 2011
0
Re: How to get server address using php
This is the only way to got your server real outside/wan IP
php Syntax (Toggle Plain Text)
  1. <?php
  2. echo file_get_contents("http://ip6.me/");
  3. ?>
Last edited by bab2501; Oct 2nd, 2011 at 5:15 pm.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
bab2501 is offline Offline
1 posts
since Oct 2011

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: Php, forms combo box
Next Thread in PHP Forum Timeline: Warning: Cannot modify header information - headers already sent by (output started a





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC