Jump to content


Photo

Browser detection


  • Please log in to reply
4 replies to this topic

#1 birdie

birdie
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts
  • LocationBirmingham UK

Posted 10 August 2006 - 12:29 AM

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

$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'";
}

Well this doesnt work because there are different versions of firefox.

Any help please?

#2 king arthur

king arthur
  • Members
  • PipPipPip
  • Advanced Member
  • 335 posts
  • LocationUK HQ

Posted 10 August 2006 - 12:33 AM

Try the get_browser() function: http://www.phpfreaks...et-browser.html
Sir Isaac Newton said "If I have seen farther, it is by standing on the shoulders of giants". But it is not recorded as to whether he said it before or after he was hit on the head by a falling apple.

#3 rab

rab
  • Members
  • PipPipPip
  • Advanced Member
  • 155 posts

Posted 10 August 2006 - 12:36 AM

http://www.zytrax.co...browser_ids.htm

Have a look at the UA strings

#4 corbin

corbin
  • Staff Alumni
  • Advanced Member
  • 8,129 posts

Posted 10 August 2006 - 12:40 AM

<?
$b = $_SERVER['HTTP_USER_AGENT'];
if(eregi('firefox', $b)) {
echo "got firefox";
}
elseif(eregi('MSIE', $b)) {
echo "got IE";
}
else { echo "Got other"; }
?>

Just tried that real quick... It works fine... ( http://corbin-dev.no...org/browser.php )
Why doesn't anyone ever say hi, hey, or whad up world?

#5 birdie

birdie
  • Members
  • PipPipPip
  • Advanced Member
  • 65 posts
  • LocationBirmingham UK

Posted 10 August 2006 - 01:23 AM

wow thanks for the quick posts, i'll try them all out :-)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users