The PHP Function GetEnv
Getenv is a php function that returns the value of an environment variable. It is a part of the Superglobals in PHP and can be used to retrieve many different pieces of information about the environment in which a script is running. For example, it can return path information, the location of the system temporary directory or other things that vary from system to system and are not a part of the normal PHP configuration.
Environment variables are a part of the configuration in which software runs and they provide a language -, OS - and system agnostic way to share common configuration. They are also a good way to limit access to your application's secrets like database credentials, secret data parameters or API keys between deployments.
The php function getenv is an associative array that stores environment variables available to the current script and can be accessed using foreach loop. The array is updated every time setenv() or unsetenv() is called and is not intended to be cached.
As a convenience, PHP also has the putenv() function that allows a program to create a new environment variable. This variable will only be available for the duration of the current request and can be retrieved using getenv().
The getenv() function can be invoked with or without an argument and either will return a string value of the environment variable or an array depending on how it is invoked. It also accepts a second argument which, if set to TRUE, will return the local environment variables only and not the ones from the Superglobals.