判断当前网站在服务器用的什么环境
点击复制代码 PHP
function GetWebServer()
{
if (!isset($_SERVER['SERVER_SOFTWARE'])) {
return SERVER_UNKNOWN;
}
$webServer = strtolower($_SERVER['SERVER_SOFTWARE']);
if (strpos($webServer, 'apache') !== false) {
return SERVER_APACHE;
} elseif (strpos($webServer, 'microsoft-iis') !== false) {
return SERVER_IIS;
} elseif (strpos($webServer, 'nginx') !== false) {
return SERVER_NGINX;
} elseif (strpos($webServer, 'lighttpd') !== false) {
return SERVER_LIGHTTPD;
} elseif (strpos($webServer, 'kangle') !== false) {
return SERVER_KANGLE;
} elseif (strpos($webServer, 'caddy') !== false) {
return SERVER_CADDY;
} elseif (strpos($webServer, 'development server') !== false) {
return SERVER_BUILTIN;
} else {
return SERVER_UNKNOWN;
}
}