$_ENV in PHP

What is $_ENV in PHP ?

$_ENV in PHP is used to return the environment variables form the web server. Please see your shell\’s documentation for a list of defined environment variables. Because it varies according to environment on which it request.

Syntax : $variable = $_ENV [\’username\’];

example:


<?php

echo \"username is \".$_ENV[\'username\'];

?>

PHP environment variables allow your scripts to glean certain types of data dynamically from the server. This supports script flexibility in a potentially changing server environment. For example, the SITE_HTMLROOT variable provided by (mt) Media Temple will automatically provide the correct path to your document root on any Grid server, without necessitating any changes in your script. (mt) Media Temple provides several dozen variables like this for your convenience.

 

These variables are imported into PHP\’s global namespace from the environment under which the PHP parser is running. Many are provided by the shell under which PHP is running and different systems are likely running different kinds of shells, a definitive list is impossible. Please see your shell\’s documentation for a list of defined environment variables.

Other environment variables include the CGI variables, placed there regardless of whether PHP is running as a server module or CGI processor.

Scroll to Top