1. Home
  2. Computing & Technology
  3. PHP / MySQL

Getenv () PHP Function

By Angela Bradley, About.com

Definition: Getenv () is used to get the value of an environmental variable. It is written as Getenv (varname) ; Below are some examples of environmental variables you can use. If you are interested, you can see a full list by running phpinfo ().
Also Known As: Get Environment Variable
Examples:
<?php
//Gets the IP address
$ip = getenv("REMOTE_ADDR") ;
Echo "Your IP is " . $ip;
?>
<?php
//Gets the document root
$root = getenv("DOCUMENT_ROOT") ;
Echo $root;
?>
<?php
//Gets the server admin's email
$ad = getenv("SERVER_ADMIN") ;
Echo $ad;
?>
Explore PHP / MySQL
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. PHP Functions
  5. PHP Getenv - Get Environment PHP - PHP Get User Data

©2009 About.com, a part of The New York Times Company.

All rights reserved.