The usage differences between getenv () and $_server in PHP:
GETENV obtains the environment variable of the system, the format of the environment variable is name=value.
Syntax: string getenv (string varname);
Return value: String function type: PHP system function
Content Description
If the environment variable varname is correctly obtained, the value of the variable is returned, and the failure returns false.
The following example can get the URL of the machine where the user's browser
<?php$ip = getenv ("remote_addr");? >
$_server is the server Super global variable array with $_server[' remote_addr ') can also obtain the IP address of the client.
The difference is that getenv does not support PHP, which is run by the ISAPI mode of IIS.
"Go" solves the difference between PHP not getting the IP address ' function getenv ("REMOTE_ADDR") and $_server[' REMOTE_ADDR ']
Recently used PHP to help friends write a vote for the page, everything is smooth, installed on the discovery: the guest IP address is not able to record (failed to obtain the IP address), strange, the original local test is good ah. The local and the server is different , immediately open a space, testing, still everything is normal. After one of the problems are excluded, know that the other side is under Windows IIS, and their own tests are on Apache , most likely this reason.
Change function immediately: replace the original IP address acquisition function "getenv (" REMOTE_ADDR ")with"$_server[' remote_addr '", overwrite the update, then look at the database, the IP address has been successfully recorded Get.
Since the problem again, it is still recorded: Php to get the guest (client) IP address function getenv ("REMOTE_ADDR") and $_server[' remote_addr ', in fact, through this matter, is already very clear. Getenv ("REMOTE_ADDR") function in Apache can obtain the IP address, and in IIS, a little function, and $_server[' remote_addr '] function, both in Apache can successfully obtain the guest's IP address, It is also valid under IIS.
Excerpt from: http://wanglianghuaihua.blog.163.com/blog/static/54251531201091211275342/
The difference between getenv () and $_server in PHP