Home>Article>Backend Development> How to receive http request header information with PHP
This article mainly talks about using PHP to receive HTTP request header information. It has certain reference value. Interested friends can learn about it.
foreach (getallheaders() as $name => $value) { echo "$name: $value\n"; }
function em_getallheaders() { $headers = []; foreach ($_SERVER as $name => $value) { if (substr($name, 0, 5) == 'HTTP_') { $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value; } } return $headers; }
Related tutorials:PHP video tutorial
The above is the detailed content of How to receive http request header information with PHP. For more information, please follow other related articles on the PHP Chinese website!