问题描述
|
这在Apache上有效,为什么它在IIS 7上似乎不起作用?
if(!function_exists(\'apache_request_headers\')) {
function apache_request_headers() {
$headers = array();
foreach($_SERVER as $key => $value) {
if(substr($key,5) == \'HTTP_\') {
$headers[str_replace(\' \',\'-\',ucwords(str_replace(\'_\',\' \',strtolower(substr($key,5)))))] = $value;
}
}
return $headers;
}
}
function getCurrentPageUrl() {
$pageURL = \'http\';
if ($_SERVER[\"HTTPS\"] == \"on\") {$pageURL .= \"s\";}
$pageURL .= \"://\";
if ($_SERVER[\"SERVER_PORT\"] != \"80\") {
$pageURL .= $_SERVER[\"SERVER_NAME\"].\":\".$_SERVER[\"SERVER_PORT\"].$_SERVER[\"REQUEST_URI\"];
} else {
$pageURL .= $_SERVER[\"SERVER_NAME\"].$_SERVER[\"REQUEST_URI\"];
}
return $pageURL;
}
$a = apache_request_headers();
$pos = strrpos($a[\"User-Agent\"],\"REBOL\");
解决方法
特定于Apache,查看文档。
http://php.net/manual/zh/function.apache-request-headers.php