PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
Bert
Forum Newbie
Posts: 6 Joined: Sat Dec 07, 2002 12:26 pm
Location: California, USA
Post
by Bert » Sat Dec 07, 2002 12:26 pm
Is there a script that I can upload to my webhost and have it tell me my webhost's IP address?
f1nutter
Forum Contributor
Posts: 125 Joined: Wed Jun 05, 2002 12:08 pm
Location: London
Post
by f1nutter » Sat Dec 07, 2002 12:53 pm
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.
hob_goblin
Forum Regular
Posts: 978 Joined: Sun Apr 28, 2002 9:53 pm
Contact:
Post
by hob_goblin » Sat Dec 07, 2002 2:15 pm
$_SERVER['SERVER_ADDR']
contains the IP of the server.
f1nutter
Forum Contributor
Posts: 125 Joined: Wed Jun 05, 2002 12:08 pm
Location: London
Post
by f1nutter » Sat Dec 07, 2002 2:25 pm
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)
Bert
Forum Newbie
Posts: 6 Joined: Sat Dec 07, 2002 12:26 pm
Location: California, USA
Post
by Bert » Sat Dec 07, 2002 5:51 pm
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
hedge
Forum Contributor
Posts: 234 Joined: Fri Aug 30, 2002 10:19 am
Location: Calgary, AB, Canada
Post
by hedge » Sat Dec 07, 2002 6:12 pm
$_SERVER['LOCAL_ADDR']
nieve
Forum Newbie
Posts: 11 Joined: Tue Dec 03, 2002 10:26 pm
Post
by nieve » Sat Dec 07, 2002 6:15 pm
did you echo it?
<?
echo "$_SERVER[SERVER_ADDR]";
?>
hob_goblin
Forum Regular
Posts: 978 Joined: Sun Apr 28, 2002 9:53 pm
Contact:
Post
by hob_goblin » Sun Dec 08, 2002 12:27 am
try
$SERVER_ADDR, or $_HTTP_SERVER_VARS['SERVER_ADDR']