Reputation: 7029
I was actually going through the question 1636644 .. and got confused with this
" The getenv() function access to any environment variable to get the related value! "
Also ..
" It would probably be better to use $_SERVER['REMOTE_ADDR']; to prevent incompatibilities between servers. "
what kind of compatibility issue can this be ??
Lastly, it says $_SERVER is an array with many elements but I find only the IP Address there .. does this array store anything else too???
apologies for all these questions packed in one .. this is bcoz these are all related ..
Upvotes: 1
Views: 265
Reputation: 11520
The function 'getenv' does not work if your Server API is ASAPI (IIS).
(source)
Also, see this link for what may be contained within the $_SERVER variable.
Upvotes: 3
Reputation: 376
$_SERVER['ROMOTE_ADDR'],ROMOTE_ADDR,getHostByName() using this 3 ways u can find ip address
Upvotes: 0
Reputation: 37065
To see what all $_SERVER
contains, just do:
echo "<pre>";
print_r($_SERVER);
echo "</pre>";
The pre tag just makes the output presentable in the browser.
To see ALL of the environmental variables that the server is setting (and tons more), make a script that just has:
<?php
phpinfo();
?>
It will be listed toward the bottom, as PHP Variables
.
The differences in environment variables can be based on the HTTP server (apache vs IIS) and other factors, such as if the page is served over SSL.
Upvotes: 1
Reputation: 53689
Create a php page containing the following to see the contents of $_SERVER along with a host of other useful information about your server.
<?php phpinfo(); ?>
Upvotes: 0
Reputation: 63586
$_SERVER may contain a lot of information; you could be interested in:
Upvotes: 1
Reputation: 18064
I think those incompatibilities would be because of the different ways that web server manage their environment variables.
The $_SERVER variable manages these differences by itself.
Answering your last question, you can access the variables of the $_SERVER array this way:
$_SERVER['SCRIPT_NAME']
$_SERVER['REQUEST_URI']
and so on... you can see the reference here: http://www.php.net/manual/en/reserved.variables.server.php
Upvotes: 0