我刚刚将我的脚本切换到不同的服务器。在以前的服务器上这工作完美,现在我已经将它们切换到不同的服务器,我无法理解这个问题。
我不确定它是否有帮助,但这是相关代码。
$headers = apache_request_headers();
PHP 版本为:PHP 5.3.2
最佳答案
可以使用如下替换函数:
<?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 );
}
///
}
///
?>
来源:PHP Manual
关于php - 调用未定义函数 apache_request_headers(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2916232/