Posted By

aristoworks on 12/23/08


Tagged

php browser detection Firefox


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

jeremyhcobb
nerdfiles
colingardom


PHP Firefox Detector


 / Published in: PHP
 

URL: http://www.aristoworks.com

This handy little script will allow you to detect whether or not a user is running FireFox as their browser.

  1. function is_firefox() {
  2. $agent = '';
  3. // old php user agent can be found here
  4. if (!empty($HTTP_USER_AGENT))
  5. $agent = $HTTP_USER_AGENT;
  6. // newer versions of php do have useragent here.
  7. if (empty($agent) && !empty($_SERVER["HTTP_USER_AGENT"]))
  8. $agent = $_SERVER["HTTP_USER_AGENT"];
  9. if (!empty($agent) && preg_match("/firefox/si", $agent))
  10. return true;
  11. return false;
  12. }

Report this snippet  

You need to login to post a comment.