Answers for "get headers of request php"

PHP
0

getallheaders()

it could be useful if you using nginx instead of apache



<?php

if (!function_exists('getallheaders')) 

{

    function 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;

    }

}

?>
Posted by: Guest on June-09-2020
0

getallheaders()

There's a polyfill for this that can be downloaded or installed via composer:

https://github.com/ralouphie/getallheaders
Posted by: Guest on June-09-2020

Code answers related to "get headers of request php"

Browse Popular Code Answers by Language