Page 1 of 1

Finding the Server's IP

Posted: Sat Dec 07, 2002 12:26 pm
by Bert
Is there a script that I can upload to my webhost and have it tell me my webhost's IP address?

Posted: Sat Dec 07, 2002 12:53 pm
by f1nutter
You can do better than that!

file: phpinfo.php

Code: Select all

<html>
<body>

<?php

 phpinfo();

?>

</body>
</html>
Upload it to your host and point your browser to the file. PHP will parse it and give you loads of useful information.

Posted: Sat Dec 07, 2002 2:15 pm
by hob_goblin
$_SERVER['SERVER_ADDR']

contains the IP of the server.

Posted: Sat Dec 07, 2002 2:25 pm
by f1nutter
or _ENV['SERVER_ADDR'], or REMOTE_HOST, or REMOTE_ADDR depending on your servers set-up. But you should be able to spot what an IP address looks like!

Call it in your scripts by placing a dollar in front of the variable you decide to use.

(These are reserved, global variables in PHP)

Posted: Sat Dec 07, 2002 5:51 pm
by Bert
None of those worked.

phpinfo(); - didnt give me the ip

$_SERVER['SERVER_ADDR']; - didnt work

$_ENV['SERVER_ADDR']; - didnt work

$REMOTE_HOST; - displayed MY IP

$REMOTE_ADDR; - displayed MY IP

If it matters, I'm using PHP 4.0.0

Posted: Sat Dec 07, 2002 6:12 pm
by hedge
$_SERVER['LOCAL_ADDR']

Posted: Sat Dec 07, 2002 6:15 pm
by nieve
did you echo it?
<?
echo "$_SERVER[SERVER_ADDR]";
?>

Posted: Sun Dec 08, 2002 12:27 am
by hob_goblin
try

$SERVER_ADDR, or $_HTTP_SERVER_VARS['SERVER_ADDR']