The difference between getenv () and $_server in PHP

Source: Internet
Author: User

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

12345 <?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 ']

The difference between getenv () and $_server in PHP

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.