What is the difference between using primarily $ _ENV vs $ SERVER?

I know the reason that $ _ENV is disabled by default and you need to enable it via php.ini. Or maybe $ _ENV serves more for its variables and $ _SERVER for accessing server configuration variables?

By default, $ _ENV contains all the same set of properties as $ _SERVER? If I correctly assumed that $ _ENV serves more for its variables, then why not then use the $ _GLOBAL array?

  • one
  • Explanatory answer .. You are not from the forum javascript.ru or htmlbook come? There such clever men are born. Where is the place for at least one answer to my questions? - zloctb
  • 2
    I do not need to poke. And the manual describes in detail what arrays are stored in. - Visman

1 answer 1

A variable like $_GLOBAL does not exist in principle.
There is a variable called $GLOBALS , but there is nothing in it that would not exist in $_ENV or $_SERVER , and it is highly undesirable to use it in general.

Therefore, we can talk only about the last two.
It is probably more correct to use $_SERVER , because, firstly, it is always available, and secondly, it may contain variables that are missing in $_ENV — for example, starting with PHP_ and some others.

$_SERVER is an internal PHP variable that he controls himself. And $_ENV is just a reflection of the list of environment variables in the system.