Getenv () and $

Source: Internet
Author: User
Welcome to the Linux community forum and interact with 2 million technical staff. In php, the difference between getenv () and $ _ SERVER usage: getenv gets the system environment variable. The environment variable format is namevalue. syntax: stringgetenv (stringvarname); Return Value: String function type: PHP system function description if the ring is obtained correctly

Welcome to the Linux community forum and interact with 2 million technical staff> enter the getenv () and $ _ SERVER usage differences in php: getenv gets the system environment variable, the environment variable format is name = value. syntax: string getenv (string varname); Return Value: string function type: PHP system function description if the ring is obtained correctly

Welcome to the Linux community forum and interact with 2 million technicians>

Difference between getenv () and $ _ SERVER in php:

Getenv obtains the system environment variable. The format of the environment variable is name = value.

Syntax: string getenv (string varname );

Return Value: String function type: PHP System Function

Description

If the environment variable varname is obtained correctly, the variable value is returned. If the variable fails, false is returned.

In the following example, you can obtain the URL of the machine where your browser is located.

$ Ip = getenv ("REMOTE_ADDR ");

?>

$ _ SERVER is the Super global variable array of the SERVER. You can use $ _ SERVER ['remote _ ADDR '] to obtain the IP address of the client.

The difference between the two is that getenv does not support php running in IIS isapi Mode

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.