1. Computing

Discuss in my forum

Getenv () PHP Function

By , About.com Guide

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; 
 ?> 
  1. About.com
  2. Computing
  3. PHP / MySQL
  4. PHP Functions
  5. PHP Getenv - Get Environment PHP - PHP Get User Data

©2013 About.com. All rights reserved.