PHP function getenv Introduction and use instance _php instance

Source: Internet
Author: User
Getenv (PHP 4, PHP 5)
Copy the Code Code as follows://getenv-Gets the value of an environment variable

Function Description:
String getenv (String $varname)
Copy the Code Code as follows://Gets the value of an environment variable.
With Phpinfo () you can see a list of all the environment variables.

Parameter description:
Copy the Code code as follows: $varname variable name.

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

Function Application Example:
The copy Code code is as follows: //getenv () Use example
$ip = getenv (' remote_addr ');

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

Through Phpinfo can see the entire PHP environment configuration information, then want to get one of the variable information to do?
Below is actually shown below, for example I want to get the following information:

So, the source code for PHP is:
Copy the 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.