pranshu82202 Posted July 14, 2011 Share Posted July 14, 2011 Is their any method by which i can get browser info of the client side... I used $_SERVER['HTTP_USER_AGENT'] but it gives Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.112 Safari/534.30 - WHEN I USED CHROME and Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1 - When i used firefox..... (I just need the browser's name then why its attaching a big string "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:2.0.1) Gecko/20100101" with every name) Quote Link to comment https://forums.phpfreaks.com/topic/241960-browser-info/ Share on other sites More sharing options...
doddsey_65 Posted July 14, 2011 Share Posted July 14, 2011 you have all of the info you need there, just extract the browser name from the string. Becareful however as chrome uses the same webkit as safari. Here is some old code of mine i managed to dig out. Im sure you could put it into a function of some sort: if (strstr($agent,"Firefox/3")) {$br = "Firefox 3";} if (strstr($agent,"Firefox/2")) {$br = "Firefox 2";} if (strstr($agent,"Firefox/1")) {$br = "Firefox 1";} if (strstr($agent,"Phoenix/")) {$br = "Phoenix (Mozilla lite)";} if (strstr($agent,"MSIE 5")) {$br = "IE 5";} if (strstr($agent,"MSIE 6")) {$br = "IE 6";} if (strstr($agent,"MSIE 7")) {$br = "IE 7";} if (strstr($agent,"MSIE 8")) {$br = "IE 8";} if (strstr($agent,"Netscape6/6")) {$br = "Netscape 6";} if (strstr($agent,"Opera")) {$br = "Opera";} if (strstr($agent,"Opera") and strstr($agent,"Version/10")) {$br = "Opera 10";} if (strstr($agent,"Opera") and strstr($agent,"Version/9")) {$br = "Opera 9";} if (strstr($agent,"Chrome")) {$br = "Chrome";} if (strstr($agent,"Chrome") and strstr($agent,"Chrome/5")) {$br = "Chrome 5";} if (strstr($agent,"Safari/")) {$br = "Safari";} if (strstr($agent,"Safari/") and strstr($agent,"Version/5")) {$br = "Safari 5";} if (strstr($agent,"Safari/") and strstr($agent,"Version/4")) {$br = "Safari 4";} if (strstr($agent,"Safari/") and strstr($agent,"Version/3")) {$br = "Safari 3";} if (strstr($agent,"SeaMonkey/") and strstr($agent,"Gecko")) {$br = "SeaMonkey";} i wouldnt reccoment using this code as is though. its from about a year ago when i was less experienced Quote Link to comment https://forums.phpfreaks.com/topic/241960-browser-info/#findComment-1242597 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.