Are they all stored in $_SERVER
? Even custom ones?
相关问题
- Views base64 encoded blob in HTML with PHP
- Angular RxJS mergeMap types
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
Every HTTP request header field is in
$_SERVER
(exceptCookie
) and the key begins withHTTP_
. If you’re using Apache, you can also tryapache_request_headers
.You can simply use
apache_request_headers()
or its aliasgetallheaders()
.Usage:
echo json_encode(getallheaders());
If above function does not exist (old PHP or nginx) you can use this as a fallback:
you can use
getallheaders()
to get an array of all HTTP headers sent.Look at the $_SERVER variable to see what it contains. The linked manual page has a lot of useful information, but also simply do a
var_dump
on it to see what's actually in it. Many of the entries will or won't be filled in, depending on what the client decides to do, and odd quirks of PHP. Looking at the one on my local server, there is also a $_SERVER["ALL_HTTP"] entries that just lists them all as a string, but apparently this isn't standard, as it isn't listed on the manual page.Try this
It will list everything within the array
you can use apache_request_header(); maybe help you.