<?PHP getenv("REMOTE_ADDR"); //get IP address of current user putenv("temp=usr"); //set an environment variable temp with value usr getenv("temp"); //usr ?>
The environment variables can be accessed with GLOBAL variable $_SERVER. However, environment variables set by putenv() can not.
<?PHP $_SERVER['REMOTE_ADDR']; //IP address of current user putenv("temp=usr"); //set an environment variable temp with value usr echo $_SERVER['temp']; //Notice : Undefined index: temp in ... ?>
PHP global environment variables include:
Some useful predefined global variables include:
<?PHP echo $_SERVER['PHP_SELF']; //result is: /program/php/environment.php echo __FILE__; //result is: http://www.endmemo.com/program/php/environment.php ?>