$_env in PHP is an array that contains 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 just passively accepts server-side environment variables and transforms them into array elements, you can try to output it directly.
When you want to see what's inside a variable, there are three ways I know it:
1, Var_dump ($_env);
2, Print_r ($_env);
3. foreach ($_env as $key = $val) {echo $key. ' --------'. $val. ' <br> ';}
Of the three ways, the first one I found most convenient and the output content format is clear.
Since the $_env variable is dependent on the environment variables of the server, the result of $_env variables obtained from different servers may be completely different. So the complete list cannot be listed like $_server. The following are the more common elements that the $_env array contains:
Sometimes, $_env is empty, and the reason for this is usually the configuration file for php php.ini: variables_order = "GPCs". To make the value of $_env not be empty, then the value of Variables_order should be prefixed with an uppercase letter "E", i.e. Variables_order = "egpcs".
The above configuration represents the source and order of external variables accepted by PHP, EGPCS is the abbreviation for environment, Get, Post, Cookies, and server. If E is missing from Variables_order's configuration, then PHP cannot accept the environment variable, then $_env is empty.
Due to the opening of $_env, that is Variables_order = "egpcs" will cause some performance loss, according to the official PHP is, in the production environment, is not recommended to use. They are more recommended to use the getenv (string $varname) function to get the value in environment, which needs to be noted during programming. If you are programming with $_env and Variables_order is not configured as Variables_order = "Egpcs", the program may run with an error.
Variables_order in PHP