Posted By

sorehead on 10/09/06


Tagged

get browser


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

Memphys
vali29
willcodeforfood
skywalker


get browser


 / Published in: PHP
 

This function determines visitor browser.

  1. <?php
  2. /*
  3. get_browser_
  4.  
  5. This function determines visitor browser.
  6. */
  7. function get_browser_($user_agent)
  8. {
  9. $browsers = array(
  10. 'Opera' => 'Opera',
  11. 'Mozilla Firefox'=> '(Firebird)|(Firefox)',
  12. 'Galeon' => 'Galeon',
  13. 'Mozilla'=>'Gecko',
  14. 'MyIE'=>'MyIE',
  15. 'Lynx' => 'Lynx',
  16. 'Netscape' => '(Mozilla/4\.75)|(Netscape6)|(Mozilla/4\.08)|(Mozilla/4\.5)|(Mozilla/4\.6)|(Mozilla/4\.79)',
  17. 'Konqueror'=>'Konqueror',
  18. 'SearchBot' => '(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp/cat)|(msnbot)|(ia_archiver)',
  19. 'Internet Explorer 6' => '(MSIE 6\.[0-9]+)',
  20. 'Internet Explorer 5' => '(MSIE 5\.[0-9]+)',
  21. 'Internet Explorer 4' => '(MSIE 4\.[0-9]+)',
  22. );
  23.  
  24. foreach($browsers as $browser=>$pattern)
  25. {
  26. if (eregi($pattern, $user_agent))
  27. return $browser;
  28. }
  29. return 'Unknown';
  30. }
  31. ?>

Report this snippet  

You need to login to post a comment.