Joker
Joker

Reputation: 1143

PHP $_SERVER variables

I noticed when I did a var_dump on the $_SERVER superglobal there were some values that were not included in the php manual here: http://www.php.net/manual/en/reserved.variables.server.php For example that page doesn't talk about the HTTP_X_FORWARDED_FOR. In my dump I also had variables like PATH, PATHEXT, etc.

Am I on the wrong page, where can I read about ALL of the $_SERVER variables? Thanks.

Upvotes: 0

Views: 647

Answers (3)

Gelmir
Gelmir

Reputation: 1857

ADDITIONALLY: $_SERVER also contains HTTP protocol variables, request headers in general, like those added by network devices [such as proxies, gateways etc], user-agents [browsers etc] and such... Since you can create your own custom protocol headers as well [those that start with "X-" prefix], the possibilities there are infinite. And of course, $_SERVER additionally contains certain server-specific variables as well, which can change in server-basis.

If you learn a little bit about HTTP protocol, I am sure it will be much clearer to you.

Upvotes: 1

Dan Lugg
Dan Lugg

Reputation: 20592

Regarding $_SERVER

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.

Details about CGI/1.1 (where these variables should be accounted for as mentioned in the quote) are here. This does not take into account (as mentioned in another answer) OS variables like PATH, and so forth.

Upvotes: 2

user646692
user646692

Reputation:

No, these aren't simply listed in the manual but are available.

Upvotes: 0

Related Questions