note 97947 deleted from function.get-browser by danbrown

From: Date: Tue, 18 May 2010 15:20:04 +0000
Subject: note 97947 deleted from function.get-browser by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-169369@lists.php.net to get a copy of this message
Note Submitter: lylesback2 ---- I made this modification to a script from earlier on. The previous script had the order of checking wrong, as Chrome uses Safari webkit, and both "Chrome" and "Safari" are used in the user agent for Chrome. I ordered Chrome to be checked before Safari, so Chrome browser doesn't show up as "Safari". <?php function get_user_browser() { $u_agent = $_SERVER['HTTP_USER_AGENT']; $ub = ''; if(preg_match('/MSIE/i',$u_agent)) { $ub = "IE"; } elseif(preg_match('/Firefox/i',$u_agent)) { $ub = "Firefox"; } elseif(preg_match('/Chrome/i',$u_agent)) { $ub = "Chrome"; } elseif(preg_match('/Flock/i',$u_agent)) { $ub = "Flock"; } elseif(preg_match('/Opera/i',$u_agent)) { $ub = "Opera"; } elseif(preg_match('/Safari/i',$u_agent)) { $ub = "Safari"; } return $ub; } ?>

« previous php.notes (#169369) next »