Re: Question
| From: | Michael Crute | Date: | Fri, 07 Oct 2005 14:11:53 +0000 |
| Subject: | Re: Question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-223732@lists.php.net to get a copy of this message | ||
On 10/7/05, Sven Simons <sven.simons@cp-a.be> wrote:
>
> I've installed PHP using the windows installer
> I try to open then php pages containing the following script :
> <?php
> echo "Current IP Address: ";
> $ipx = getenv("HTTP_CLIENT_IP") ? getenv("HTTP_CLIENT_IP") : 0;
> $ipx = !$ipx && getenv("HTTP_X_FORWARDED_FOR") ?
> getenv("HTTP_X_FORWARDED_FOR") : 0 ;
> $ipx = !$ipx && getenv("REMOTE_ADDR") ? getenv("REMOTE_ADDR") : 0 ;
> echo !$ipx ? "UNKNOWN" : $ipx;
>
> echo "<br>";
>
> echo "Server IP Address: ";
> $ipx = getenv("SERVER_ADDR") ? getenv("SERVER_ADDR") : 0;
> echo !$ipx ? "UNKNOWN" : $ipx;
> ?>
> It works and gives me a correct current IP address
>
> When manually installing PHP it always gives me the status UNKNOWN.
>
>
Just use the $_SERVER[] superglobal array to grab the stuff you need. Don't
use the getenv function.
-Mike
--
________________________________
Michael E. Crute
Software Developer
SoftGroup Development Corporation
Linux, because reboots are for installing hardware.
"In a world without walls and fences, who needs windows and gates?"