PHP Variable ENV

$_ENV is an array containing the server-side environment variables. It is a super global variable in PHP, and we can access it directly from anywhere in the PHP program.

$_ENV only passive to accept the server-side environment variables and convert them to an array of elements, you can try to print it directly:


Due to space limitations, the results are no longer listed here, and the results printed on different servers may be completely different.

$_ENV array element

The elements in the $_ENV array(array elements) vary considerably depending on the server environment, so they can not be compared to $_SERVER to list the complete list. The following are the more general elements of the $_ENV array:

  • $_SERVER['PATH']: environment variable PATH path.
  • $_SERVER['CLASSPATH']: The system's CLASSPATH path.
  • $_SERVER['LIB']: System LIB library path.
  • $_SERVER['INCLUDE']: Include the path to the system, noting that it is not the same as the include path of PHP.
  • $_SERVER['OS']: Operating system type.
  • $_SERVER['LANG']: System language, such as en_US.
  • $_SERVER['PWD']: Current working directory.
  • $_SERVER['TEMP']: The system TEMP path.
  • $_SERVER['AP_PARENT_PID']: Current process ID number.
  • $_SERVER['NUMBER_OF_PROCESSORS']: Number of system CPUs.

$_ENV causes and solutions for empty

If the printed output $_ENV is empty, you can check the php.ini configuration:

variables_order = "EGPCS "

The above configuration indicates the source and order of external variables that PHP accepts. EGPCS is an abbreviation for Environment, Get, Post, Cookies, and Server. If E is missing from the configuration of variables_order, PHP can not accept environment variables, so $_ENV is empty.

Copyright 2014-2017 by All Rights Reserved.