php - 调用未定义函数 apache_request_headers()

标签 php

我刚刚将我的脚本切换到不同的服务器。在以前的服务器上这工作完美,现在我已经将它们切换到不同的服务器,我无法理解这个问题。

我不确定它是否有帮助,但这是相关代码。

$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/

相关文章:

javascript - 使用 POST 打开新选项卡或窗口 [PHP]

php - 枚举mysql查询中使用的表?

php - Paypal 的自定义值和取回

php - 在 Laravel 5.3 中强制换行

php - 注意第 19 行调用堆栈上的 : Undefined variable: row in . ..uredi.php #TimeMemoryFunctionLocation

php - 从YouTube API批量下载图像

php - 如何在使用 composer 省略选择文件的同时需要一个包

javascript - HTML 在不提交数据的情况下从输入填充选择菜单?

php - 如何知道你是否在 PHP/MySQL mysql_fetch_array() 中的第一条记录上

php - 将 CodeIgniter (PHP) 与 Backbone Js 混合使用