note 10232 added to get_browser
| From: | fil at rezox dot com | Date: | Wed, 20 Dec 2000 11:06:50 +0000 |
| Subject: | note 10232 added to get_browser | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-8947@lists.php.net to get a copy of this message | ||
Here's some quick code that will set 2 variables '$isie' and '$isns'.
---------------------------------
## GET BROWSER VERSION (NS/IE Check)
$isiepos = strpos($HTTP_USER_AGENT,"MSIE");
$isie = ( $isiepos>0 ? substr($HTTP_USER_AGENT,$isiepos+5,3) : 0 );
list($isnsver,$d) = explode(" ",$HTTP_USER_AGENT);
$isnsver = ( substr($isnsver,0,8)=="Mozilla/" ? substr( $isnsver,8 ) : 0 );
$isns = ( $isnsver>4.0 ? $isnsver : 0 );
---------------------------------
EXAMPLE: Let's say you have some formatting html that is for Netscape 6 (Mozilla/5.0) &
Internet Explorer:
if( $isie>=4 || $isns>=5 ){
NS6/IE4/IE5 stuff goes here
} else {
other (ex NS4)
};
http://www.php.net/manual/function.get-browser.php