Some header information exists in the system and cannot be changed, such as host and user_agent. Note that we often use $ _ server ['HTTP _ host'], $ _ server ['HTTP _ user_agent '], which has an HTTP prefix. In this case, there is no HTTP prefix in the header information, and the information name is only host or the like, $ _ server automatically adds an HTTP prefix to them. 1 is to prevent conflicts with other information, and 2 is to indicate that they are header information. therefore, all the variables in $ _ server with an HTTP prefix are header information, but none are available, for example, $ _ server ['query _ string']. $ _ server ['php _ Self '] and so on.
You can create custom header information and send the information to the server. The server records the header information and stores them in the $ _ server variable, of course, the variable name is changed to "HTTP _" connected to the user's variable name. for example, the above Ajax request is judged. in fact, before sending an asynchronous request to the server, add a header to the header. The actual statement should be:
Httprequest object. setRequestHeader ("x_requested_with", "arbitrary string"); whether the server exists through $ _ server ['HTTP _ x_requested_with, or a specific value to determine whether it is an Ajax request or which Ajax request is required. therefore, this not only verifies whether the request is an Ajax request, but also obtains more information.
We can also set any other information in the header for data exchange with the server.
For example, XMLHttpRequest. setRequestHeader ("test", "just a test"); then the value of the variable $ _ server ['HTTP _ test'] on the requested Server Page is "just a test "; note that the test in front of it is not case sensitive. $ _ server ['HTTP _ test'] must be capitalized.