Created
September 12, 2017 07:58
-
-
Save ryonakae/9f5e99c92ac9986791166438aa14cc53 to your computer and use it in GitHub Desktop.
PHPでgetallheaders()が動かない時用の関数 https://stackoverflow.com/questions/13224615/get-the-http-headers-from-current-request-in-php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!function_exists('getallheaders')) { | |
function getallheaders() { | |
$headers = array(); | |
foreach ($_SERVER as $name => $value) { | |
if (substr($name, 0, 5) == 'HTTP_') { | |
$headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value; | |
} | |
} | |
return $headers; | |
} | |
} | |
// ヘッダー情報を出力 | |
print_r(getallheaders()); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment