Home > Backend Development > PHP Tutorial > Introduction to the use of PHP function getenv_PHP tutorial

Introduction to the use of PHP function getenv_PHP tutorial

WBOY
Release: 2016-07-13 10:29:58
Original
1072 people have browsed it

Share an example of using the PHP function getenv. The getenv function is mainly used to obtain the value of an environment variable. Common PHP probe programs use the getenv function.

getenv(PHP 4, PHP 5)
// getenv — Get the value of an environment variable
Function description: www.jbxue.com
string getenv ( string $varname )

// Get the value of an environment variable.
// Using phpinfo() you can see a list of all environment variables.
Parameter description:
$varname variable name.
Function return value:
// Returns the value of the environment variable varname. If the environment variable varname does not exist, it returns FALSE.
Function application example:

<?<span>php
</span><span>//</span><span> getenv() 使用示例</span>
<span>$ip</span> = <span>getenv</span>('REMOTE_ADDR'<span>);
</span><span>//</span><span> 或简单仅使用全局变量($_SERVER 或 $_ENV)</span>
<span>$ip</span> = <span>$_SERVER</span>['REMOTE_ADDR'<span>];
</span>?>
Copy after login

You can see the configuration information of the entire PHP environment through phpinfo, so what should you do if you want to get one of the variable information?

Get the following information:

php code:

<span>echo</span> <span>getenv</span>('userprofile');<span>//</span><span> C:\Windows\system32\config\systemprofile</span>
Copy after login

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/768445.htmlTechArticle Share an example of using the PHP function getenv. The getenv function is mainly used to obtain the value of an environment variable. Common PHP exploration All programs use the getenv function. getenv(PHP 4, PHP 5) // getenv gets...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template