PHP - $ _SERVER属性来自哪里? [关闭]

In php the $_SERVER global has a lot of info regarding the request etc but where are these set?

Are these provided by apache through some api?

Or is php getting them from somwehere else? If so where?

If you look at the PHP Manual it says (URL: http://php.net/manual/en/reserved.variables.server.php)

$_SERVER is an array containing information such as headers, paths, and script locations. The entries in this array are created by the web server. There is no guarantee that every web server will provide any of these; servers may omit some, or provide others not listed here. That said, a large number of these variables are accounted for in the » CGI/1.1 specification, so you should be able to expect those.

$HTTP_SERVER_VARS contains the same initial information, but is not a superglobal. (Note that $HTTP_SERVER_VARS and $_SERVER are different variables and that PHP handles them as such)

So it comes from Apache if you use Apache. Otherwise from some other server.

From the PHP documentation:

$_SERVER is an array containing information such as headers, paths, and script locations. The entries in this array are created by the web server. There is no guarantee that every web server will provide any of these; servers may omit some, or provide others not listed here.