Detect Firefox browser with php script/function

Home » PHP » Detect Firefox browser with php script/function
Date: 2006-01-27
Link: http://php.devquickref.com/php-firefox-browser-detection-php-script.html

Detect Firefox browser with php script/function

 
/**
    * checks for user agent whether this is firefox or not
    * @param void
    * @return bool
    * @author svetoslavm##gmail.com
    * @link http://devquickref.com/
*/
function is_firefox() {
    $agent = '';
    // old php user agent can be found here
    if (!empty($HTTP_USER_AGENT))
        $agent = $HTTP_USER_AGENT;
    // newer versions of php do have useragent here.
    if (empty($agent) && !empty($_SERVER["HTTP_USER_AGENT"]))
        $agent = $_SERVER["HTTP_USER_AGENT"];
    if (!empty($agent) && preg_match("/firefox/si", $agent))
        return true;
    return false;
}