note 27862 added to function.get-browser
| From: | bart at friesoft dot nl | Date: | Sat, 21 Dec 2002 12:29:26 +0000 |
| Subject: | note 27862 added to function.get-browser | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-41180@lists.php.net to get a copy of this message | ||
Another way, not depending on the actual browser version is this one (it parses the $HTTP_USER_AGENT
string):
preg_match_all("/[\w\.]+\/[\w\.]+/", $HTTP_USER_AGENT, $browser);
preg_match_all("/\(.*\)/", $HTTP_USER_AGENT, $features);
$browser = $browser[0]; foreach ($browser as $key=>$value) {
$brow_ver = explode("/", $value);
$browser[$brow_ver[0]] = $brow_ver[1];
unset($browser[$key]);
}
$features = $features[0][0];
$features = substr($features, 1, -1);
$features = explode("; ", $features);
At the end you have two arrays: $browser, which is an associative array that holds the browser types
and version (mozilla for example has Mozilla => 5.0 and Gecko => 20020304) and $features that
holds the features of the browser (use rv:<moz-version> to see the build of Mozilla).
--
http://www.php.net/manual/en/function.get-browser.php
http://master.php.net/manage/user-notes.php?action=edit+27862
http://master.php.net/manage/user-notes.php?action=delete+27862
http://master.php.net/manage/user-notes.php?action=reject+27862