Tanımsız işlev apache_request_headers Çağrı ()

2 Cevap

Ben sadece farklı bir sunucuya benim komut açık ettik. Önceki sunucuda bu kusursuz çalıştı ve şimdi farklı bir sunucuya açık ettik, ben sorunu anlayamıyorum.

Ben yardımcı olacağını emin değilim, ama burada ilgili kod.

$headers = apache_request_headers();

PHP Version: PHP 5.3.2

Herhangi bir yardım mutluluk duyacağız.

2 Cevap

Kimden docs:

PHP bir Apache modülü olarak kurulduğunda, bu fonksiyon sadece desteklenir.

Docs, $_SERVER gözatarak apache_request_headers işlevselliğini taklit yedek fonksiyonları içerir söyledi.

Aşağıdaki yedek işlevini kullanabilirsiniz:

<?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 );
}
///
}
///
?>

Source: PHP Manual