php获取网站在服务器中用的环境
时间:2023年09月19日
/来源:网络
/编辑:佚名
判断当前网站在服务器用的什么环境
点击复制代码 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;
}
}
点击复制代码 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;
}
}
新闻资讯 更多
- 【建站知识】查询nginx日志状态码大于400的请求并打印整行04-03
- 【建站知识】Python中的logger和handler到底是个什么?04-03
- 【建站知识】python3拉勾网爬虫之(您操作太频繁,请稍后访问)04-03
- 【建站知识】xpath 获取meta里的keywords及description的方法04-03
- 【建站知识】python向上取整以50为界04-03
- 【建站知识】scrapy xpath遇见乱码解决04-03
- 【建站知识】scrapy爬取后中文乱码,解决word转为html 时cp1252编码问题04-03
- 【建站知识】scrapy采集—爬取中文乱码,gb2312转为utf-804-03