Aryeh Beitz
Aryeh Beitz

Reputation: 2078

Why is the PHP $_SERVER mixed with client and server values

I just did a print_r on $_SERVER.

It contains SCRIPT_FILENAME which is known only on the receiving end, but it also has HTTP_USER_AGENT which came from the browser sending the form.

Is there a way to separate the values?
For example, if I use the Google DevTools in Chrome, it's seperated into Response Headers and Request Headers.
Why are they grouped together in PHP and how can I seperate them?

Upvotes: 0

Views: 35

Answers (1)

arkascha
arkascha

Reputation: 42875

That super global variable collects all technical details of interest available about the request. It is neither server nor client specific.

There is no automatic approach to separate those, since it is an arbitrary, hard coded collection. You can only create a dictionary yourself picking which values you connect with which side (which is ambiguous...). Take a look at the documentation for a list of all potential fields: http://php.net/manual/en/reserved.variables.server.php

Upvotes: 1

Related Questions