Introduction to the PHP function getenv and the use of instance _ PHP Tutorial-php Tutorial

Source: Internet
Author: User
Introduction and use of the PHP function getenv. The getenv (PHP4, PHP5) Copy code is as follows: getenv-function description for getting the value of an environment variable: stringgetenv (string $ varname) copy the code as follows: Get a getenv (PHP 4, PHP 5)

The code is as follows:

// Getenv-get the value of an environment variable

Function description:
String getenv (string $ varname)

The code is as follows:

// Obtain the value of an environment variable.
// Use phpinfo () to view the list of all environment variables.

Parameter description:

The code is as follows:

$ Varname variable name.

Function return value:

The code is as follows:

// Return the value of the environment variable varname. if the environment variable varname does not exist, FALSE is returned.

Function application example:

The code is as follows:

// Getenv () example
$ Ip = getenv ('remote _ ADDR ');

// Or simply use only global variables ($ _ SERVER or $ _ ENV)
$ Ip = $ _ SERVER ['remote _ ADDR '];
?>

You can see the configuration information of the entire PHP environment through phpinfo. what if you want to get the information of one of the variables?
The following is an example of how to obtain the following information:

The PHP source code is:

The code is as follows:

Echo getenv ('userprofile '); // C: \ Windows \ system32 \ config \ systemprofile

Is it Easy? Hey ~

Http://www.bkjia.com/PHPjc/769245.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/769245.htmlTechArticlegetenv (PHP 4, PHP 5) Code: // getenv-get the value of an environment variable function description: string getenv (string $ varname) code is as follows: // Get...

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.