Page 1 of 1

$_SERVER problem

Posted: Sat Mar 13, 2004 2:58 am
by softsolvers
Hello friends,
I am unable to find the ip address of the server,i am using following code.
<?php
echo $_SERVER['SERVER_ADDR'];
?>
But i am unable to see the address, i have register_global=on in my php.ini file is it make any problem .In a project i have to put register_global to on ,now how can i view the ip address of the server.
Plz. suggest me
Softsolvers

Posted: Sat Mar 13, 2004 4:36 am
by Gen-ik
Try $_SERVER["REMOTE_ADDR"];

Posted: Sat Mar 13, 2004 7:40 am
by evilcoder
its

Code: Select all

$_SERVER&#1111;"HTTP_HOST"];

Posted: Sat Mar 13, 2004 10:22 am
by Illusionist
evilcoder wrote:its

Code: Select all

$_SERVER&#1111;"HTTP_HOST"];
No evilcoder it is not. HTTP_HOST wil echo out the host. Like google.com or forums.devnetwork.net

Posted: Sat Mar 13, 2004 10:24 am
by Illusionist
you might want to try:

Code: Select all

echo getenv("SERVER_ADDR");

Posted: Sat Mar 13, 2004 12:57 pm
by penguinboy
Try:

Code: Select all

print '<pre>';
print_r($_SERVER);
Among others; you'll see:

Code: Select all

$_SERVER['SERVER_ADDR']
I believe it is undocumented.

Posted: Sat Mar 13, 2004 9:08 pm
by Illusionist
yeah your right penquinboy. Even if you do phpinfo() it will come up with a list of all the $_SERVER vars, and yes $_SERVER['SERVER_ADDR'] is on there!

Posted: Mon Mar 15, 2004 4:35 am
by twigletmac
What's available in the $_SERVER array is governed by the server - not all elements will be available on all servers, best thing to do is what penguinboy suggested -

Code: Select all

echo '<pre>';
print_r($_SERVER);
echo '</pre>';
that way you can see what's available on your server and can find the information you are looking for.

Mac