Reputation: 21
In the PHP source code, I echo out $_SERVER
in one of my domain on server A and got returns me a list of data include DOCUMENT_ROOT
and GATEWAY_INTERFACE
and etc. However, in the another domain in server B didn't return me anything when I echo out same things. Can I know why?
Upvotes: 1
Views: 569
Reputation: 4691
Just summarizing the comments, including my own.
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.
While most servers will provide at least certain values within $_SERVER
, there are no guarantees. Either design your code in a way that does not depend on the content of $_SERVER
, or make sure that the very server you are going to use in production does in fact provide the values you need.
Upvotes: 2