Last active
April 22, 2018 14:38
-
-
Save yesasha/eac5ae5da3c339c09e476ffe0274e28f to your computer and use it in GitHub Desktop.
http_responce_code function polyfill #2 from http://php.net/manual/en/function.http-response-code.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 | |
/** | |
* http_responce_code function polyfill. | |
* http://php.net/manual/en/function.http-response-code.php | |
* | |
* @param number $code | |
* @return string | |
*/ | |
if (!function_exists('http_response_code')) { | |
function http_response_code ($code = NULL) { | |
$prev_code = (isset($GLOBALS['http_response_code']) ? $GLOBALS['http_response_code'] : 200); | |
if ($code === NULL) { | |
return $prev_code; | |
} | |
header('X-Temporary-Header: none', true, $code); | |
header_remove('X-Temporary-Header'); | |
$GLOBALS['http_response_code'] = $code; | |
return $prev_code; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment