note 25730 added to function.get-browser
| From: | gunnerx at mnc dot com dot br | Date: | Thu, 03 Oct 2002 12:34:35 +0000 |
| Subject: | note 25730 added to function.get-browser | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-37622@lists.php.net to get a copy of this message | ||
I used something like this for the operatinal system and browser:
function ckos() {
$so = $_SERVER['HTTP_USER_AGENT'];
$windowsxp = preg_match("/windows nt 5.1/i", $so);
$windowsxp2 = preg_match("/windows xp/i", $so);
$linux = preg_match("/linux/i", $so);
$windowsme = preg_match("/win 9x 4.90/i", $so);
$windowsme2 = preg_match("/windows me/i", $so);
$windows2k = preg_match("/windows nt 5.0/i", $so);
$windows2kb = preg_match("/windows 2000/i", $so);
$windowsnt = preg_match("/windows nt 3.1/i", $so);
$windowsnt2 = preg_match("/windows nt 3.5.0/i", $so);
$windowsnt3 = preg_match("/windows nt 3.5.1/i", $so);
$windowsnt4 = preg_match("/windows nt 4.0/i", $so);
$windows98 = preg_match("/windows 98/i", $so);
$windows95 = preg_match("/windows 95/i", $so);
if ($windowsxp == 1 or $windowsxp2 == 1) {
$sys = "Windows XP";
} else if ($linux == 1) {
$sys = "Linux";
} else if ($windowsme == 1 or $windowsme2 == 1) {
$sys = "Windows ME";
} else if ($windows2k == 1 or $windows2kb == 1) {
$sys = "Windows 2000";
} else if ($windowsnt == 1 or $windowsnt2 == 1 or $windowsnt3 == 1 or $windowsnt4 == 1) {
$sys = "Windows NT";
} else if ($windows98 == 1 and $windowsme != 1) {
$sys = "Windows 98";
} else if ($windows95 == 1) {
$sys = "Windows 95";
} else {
$sys = "Not identified";
}
return($sys);
}
---
function ckbrowser() {
$b = $_SERVER['HTTP_USER_AGENT'];
$ie50 = preg_match("/MSIE 5.0/i", $b);
$ie55 = preg_match("/MSIE 5.5/i", $b);
$ie60 = preg_match("/MSIE 6.0/i", $b);
$opera = preg_match("/opera/i", $b);
if ($ie40 == 1) {
$browser = "Internet Explorer 4.0";
} else if ($ie50 == 1) {
$browser = "Internet Explorer 5.0";
} else if ($ie55 == 1) {
$browser = "Internet Explorer 5.5";
} else if ($ie60 == 1) {
$browser = "Internet Explorer 6.0";
} else if ($opera == 1) {
$browser = "Opera";
} else {
$browser = "Not identified";
}
return($browser);
}
Well, at least, it worked for me.
PS. It's just a test, so do not laugh at the code :)
--
http://www.php.net/manual/en/function.get-browser.php
http://master.php.net/manage/user-notes.php?action=edit+25730
http://master.php.net/manage/user-notes.php?action=delete+25730
http://master.php.net/manage/user-notes.php?action=reject+25730