PHP判断服务器使用apache还是nginx的方法
方法
if (!isset($_SERVER['SERVER_SOFTWARE'])) {
echo '未检测到服务器类型';
}
$webServer = strtolower($_SERVER['SERVER_SOFTWARE']);
if (strpos($webServer, 'apache') !== false) {
echo 'apache服务器';
} elseif (strpos($webServer, 'microsoft-iis') !== false) {
echo 'iis服务器';
} elseif (strpos($webServer, 'nginx') !== false) {
echo 'nginx服务器';
} elseif (strpos($webServer, 'lighttpd') !== false) {
echo 'lighttpd服务器';
} elseif (strpos($webServer, 'kangle') !== false) {
echo 'kangle服务器';
} elseif (strpos($webServer, 'caddy') !== false) {
echo 'caddy服务器';
} elseif (strpos($webServer, 'development server') !== false) {
echo 'development server 服务器';
} else {
echo $webServer;
}
?>
来源地址:https://blog.csdn.net/qikexun/article/details/130869706