Re: IP address
| From: | Jason Brooke | Date: | Tue, 31 Oct 2000 00:57:20 +0000 |
| Subject: | Re: IP address | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-22797@lists.php.net to get a copy of this message | ||
> How do you get the IP address of the client?
>
> Liam Gibbs
There's a bunch of standard cgi environment variables that are also
available to you when you're not necessarily using the cgi, ie: php
apache module. One of them is called REMOTE_ADDR - it contains the ip
address of the client (or the real client's proxy if any)
To print out the address of the client, you would simply do:
<?php echo $REMOTE_ADDR; ?>
or to be sure it's coming from the environment:
<?php echo getenv("REMOTE_ADDR"); ?>
There's a list of some/all of these environment variables here:
http://www.php.net/manual/language.variables.predefined.php
Another thing you can do to see what information is available to you
when developing with php is to make a page with the following in it:
<?php phpinfo(); ?>
...and then view it in your web browser - it outputs lots of
information. It's a good idea to protect this page from public access
though, since it reveals some info about your server that you might not
want everyone to know.
jason