本人亲测,但是存在一个小问题,就是用此方法在手机端打开会显示Google Chrome,但是在PC端是没有问题的,现在还在测试,先把第一版代码分享给大家!
if(strpos($_SERVER['HTTP_USER_AGENT'],"MicroMessenger") !== false){ echo "weixin"; }else{ if(strpos($_SERVER["HTTP_USER_AGENT"],"MSIE 8.0")) echo "Internet Explorer 8.0"; // 这里可以写其他的执行命令 else if(strpos($_SERVER["HTTP_USER_AGENT"],"MSIE 7.0")) echo "Internet Explorer 7.0"; else if(strpos($_SERVER["HTTP_USER_AGENT"],"MSIE 6.0")) echo "Internet Explorer 6.0"; else if(strpos($_SERVER["HTTP_USER_AGENT"],"Firefox/3")) echo "Firefox 3"; else if(strpos($_SERVER["HTTP_USER_AGENT"],"Firefox/2")) echo "Firefox 2"; else if(strpos($_SERVER["HTTP_USER_AGENT"],"Chrome")) echo "Google Chrome"; else if(strpos($_SERVER["HTTP_USER_AGENT"],"Safari")) echo "Safari"; else if(strpos($_SERVER["HTTP_USER_AGENT"],"Opera")) echo "Opera"; else echo $_SERVER["HTTP_USER_AGENT"]; }