Introduction to PHP functions getenv and examples of _php usages

Source: Internet
Author: User
Tags phpinfo

Getenv (PHP 4, PHP 5)

Copy Code code as follows:
Getenv-gets the value of an environment variable

Function Description:
String getenv (String $varname)

Copy Code code as follows:
Gets the value of an environment variable.
Using Phpinfo () you can see a list of all the environment variables.

Parameter description:

Copy Code code as follows:
$varname variable name.

function return value:

Copy Code code as follows:
Returns the value of the environment variable varname, or FALSE if the environment variable varname does not exist.

Function Application instance:

Copy Code code as follows:
<?php
Getenv () using the example
$ip = getenv (' remote_addr ');

Or simply use global variables ($_server or $_env)
$ip = $_server[' remote_addr '];
?>

You can see the configuration information for the entire PHP environment through phpinfo, so what do you want to get one of the variable information?
Below the actual display, for example I want to get the following information:

So, the source code of PHP is:

Copy Code code as follows:
echo getenv (' userprofile ');//C:\Windows\system32\config\systemprofile

Easy, huh? Hey!

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.