/**
* PHP检测客户端浏览器类型代码
*
* @param
* @arrange 512-笔记网: jb51.cc
**/
$viewer = getenv( "HTTP_USER_AGENT" );
$browser = "An unidentified browser";
if( preg_match( "/MSIE/i","$viewer" ) )
{
$browser = "Internet Explorer";
}
else if( preg_match( "/Netscape/i","$viewer" ) )
{
$browser = "Netscape";
}
else if( preg_match( "/Mozilla/i","$viewer" ) )
{
$browser = "Mozilla";
}
$platform = "An unidentified OS!";
if( preg_match( "/Windows/i","$viewer" ) )
{
$platform = "Windows!";
}
else if ( preg_match( "/Linux/i","$viewer" ) )
{
$platform = "Linux!";
}
echo("You are using $browser on $platform");
/*** 来自编程之家 jb51.cc(jb51.cc) ***/
输出结果如下You are using Mozilla! on Windows! 原文链接:https://www.f2er.com/php/528296.html