php检测客户端浏览器类型的简单示例

前端之家收集整理的这篇文章主要介绍了php检测客户端浏览器类型的简单示例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
PHP检测客户端浏览器类型代码感兴趣的小伙伴,下面一起跟随编程之家 jb51.cc的小编两巴掌来看看吧!

/**
 * 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

猜你在找的PHP相关文章