Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 调用未定义的函数apache_request__Php_Apache_Http_Slim - Fatal编程技术网

Php 调用未定义的函数apache_request_

Php 调用未定义的函数apache_request_,php,apache,http,slim,Php,Apache,Http,Slim,我之所以发布这个帖子,是因为其他帖子都没有帮我解决问题。我正在chrome上使用slim和高级RESTAPI应用程序进行测试。我在网上尝试了很多建议,但都不管用。我正在hostgator上运行PHP5.5。我在传递授权标头时遇到错误: 调用未定义的函数apache_request_headers() PHP5.4.0及更高版本支持apache_请求_头()。但还有其他解决方案,如下面的代码,它来自: PHP5.4.0及更高版本支持apache_请求_头()。但还有其他解决方案,如下面的代码,它来

我之所以发布这个帖子,是因为其他帖子都没有帮我解决问题。我正在chrome上使用slim和高级RESTAPI应用程序进行测试。我在网上尝试了很多建议,但都不管用。我正在hostgator上运行PHP5.5。我在传递授权标头时遇到错误:

调用未定义的函数apache_request_headers()


PHP5.4.0及更高版本支持apache_请求_头()。但还有其他解决方案,如下面的代码,它来自:


PHP5.4.0及更高版本支持apache_请求_头()。但还有其他解决方案,如下面的代码,它来自:


更新,这似乎解决了标题问题

   if (!function_exists('apache_request_headers')) { 


       function apache_request_headers() { 
            foreach($_SERVER as $key=>$value) { 
                if (substr($key,0,5)=="HTTP_") { 
                    $key=str_replace(" ","-",ucwords(strtolower(str_replace("_"," ",substr($key,5))))); 
                    $out[$key]=$value; 
                }else{ 
                    $out[$key]=$value; 
        } 
            } 
            return $out; 
        } 
} 

更新,这似乎解决了标题问题

   if (!function_exists('apache_request_headers')) { 


       function apache_request_headers() { 
            foreach($_SERVER as $key=>$value) { 
                if (substr($key,0,5)=="HTTP_") { 
                    $key=str_replace(" ","-",ucwords(strtolower(str_replace("_"," ",substr($key,5))))); 
                    $out[$key]=$value; 
                }else{ 
                    $out[$key]=$value; 
        } 
            } 
            return $out; 
        } 
} 

函数apache-request-headers(),如果仅适用于apache。Hostgrator很可能使用了其他东西,如Nginx。如果仅适用于apache,我在本地机器函数apache-request-headers()上也会遇到同样的错误。Hostgrator很可能使用了其他东西,比如Nginx。我在本地机器上遇到了相同的错误
function apache_request_headers() {
  $arh = array();
  $rx_http = '/\AHTTP_/';
  foreach($_SERVER as $key => $val) {
    if( preg_match($rx_http, $key) ) {
      $arh_key = preg_replace($rx_http, '', $key);
      $rx_matches = array();
      // do some nasty string manipulations to restore the original letter case
      // this should work in most cases
      $rx_matches = explode('_', $arh_key);
      if( count($rx_matches) > 0 and strlen($arh_key) > 2 ) {
        foreach($rx_matches as $ak_key => $ak_val) $rx_matches[$ak_key] = ucfirst($ak_val);
        $arh_key = implode('-', $rx_matches);
      }
      $arh[$arh_key] = $val;
    }
  }
  return( $arh );
}
   if (!function_exists('apache_request_headers')) { 


       function apache_request_headers() { 
            foreach($_SERVER as $key=>$value) { 
                if (substr($key,0,5)=="HTTP_") { 
                    $key=str_replace(" ","-",ucwords(strtolower(str_replace("_"," ",substr($key,5))))); 
                    $out[$key]=$value; 
                }else{ 
                    $out[$key]=$value; 
        } 
            } 
            return $out; 
        } 
}