birdie Posted August 10, 2006 Share Posted August 10, 2006 Hi, i know $_SERVER['http_user_agent'] provides 'browser' detection but it just doesnt work simply.Is there any way you can basically but this variable or another 1 which can do a relatively similiar action.Example of the script[code]$browser = $_SERVER['http_user_agent'];if(eregi('Firefox', $browser)){$sql = "UPDATE sitestats_browser SET firefox='$firefox'";}elseif(eregi('MSIE', $browser)){$sql = "UPDATE sitestats_browser SET ie='$internetexplorer'";}else{$sql = "UPDATE sitestats_browser SET other='$other'";}[/code]Well this doesnt work because there are different versions of firefox.Any help please? Link to comment https://forums.phpfreaks.com/topic/17086-browser-detection/ Share on other sites More sharing options...
king arthur Posted August 10, 2006 Share Posted August 10, 2006 Try the get_browser() function: [url=http://www.phpfreaks.com/phpmanual/page/function.get-browser.html]http://www.phpfreaks.com/phpmanual/page/function.get-browser.html[/url] Link to comment https://forums.phpfreaks.com/topic/17086-browser-detection/#findComment-72150 Share on other sites More sharing options...
rab Posted August 10, 2006 Share Posted August 10, 2006 [url=http://www.zytrax.com/tech/web/browser_ids.htm]http://www.zytrax.com/tech/web/browser_ids.htm[/url]Have a look at the UA strings Link to comment https://forums.phpfreaks.com/topic/17086-browser-detection/#findComment-72151 Share on other sites More sharing options...
corbin Posted August 10, 2006 Share Posted August 10, 2006 [code=php:0]<?$b = $_SERVER['HTTP_USER_AGENT'];if(eregi('firefox', $b)) {echo "got firefox";}elseif(eregi('MSIE', $b)) {echo "got IE";}else { echo "Got other"; }?>[/code]Just tried that real quick... It works fine... ( http://corbin-dev.no-ip.org/browser.php ) Link to comment https://forums.phpfreaks.com/topic/17086-browser-detection/#findComment-72156 Share on other sites More sharing options...
birdie Posted August 10, 2006 Author Share Posted August 10, 2006 wow thanks for the quick posts, i'll try them all out :-) Link to comment https://forums.phpfreaks.com/topic/17086-browser-detection/#findComment-72190 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.