我刚刚将脚本切换到另一台服务器.在以前的服务器上,这完美无缺,现在我已经将它们切换到不同的服务器,我无法理解这个问题.
我不确定它会有所帮助,但这是相关的代码.
$headers = apache_request_headers();
PHP版本是:PHP 5.3.2
任何帮助,将不胜感激.
Bab*_*emi 56
您可以使用以下替换功能:
<?php
if( !function_exists('apache_request_headers') ) {
///
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 );
}
///
}
///
?>
Run Code Online (Sandbox Code Playgroud)
来源:PHP手册
cee*_*yoz 27
从文档开始,在PHP 5.4.0发布之前:
仅当PHP作为Apache模块安装时,才支持此功能.
PHP 5.4.0及更高版本无条件地支持此功能.
所述文档还包括apache_request_headers
通过单步模拟功能的替换功能$_SERVER
.
Cha*_*dla 17
如果php作为Apache模块安装:
apache_request_headers()["Authorization"];
Run Code Online (Sandbox Code Playgroud)
否则,转到.htaccess文件并添加:
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
Run Code Online (Sandbox Code Playgroud)
然后,您可以使用以下任意方式访问请求标头:
$_SERVER["HTTP_AUTHORIZATION"]; // using super global
Run Code Online (Sandbox Code Playgroud)
要么
$app->request->headers("Authorization"); // if using PHP Slim
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
34947 次 |
最近记录: |