i just recently learned regexps, and so im having a bit of trouble with them...im trying to make a PHP browser detector, and i have most of it worked out, but im trying to figure out a way to find the difference between netscape and mozilla...heres Netscape's user agent, um, thing:
now how do i use a regexp to determine whether a browser is mozilla or not, either searching for "Mozilla" twice, or making sure "Netscape" and "MSIE" are not listed inside the user agent...thanx for the help
cmon people, does no one know regular expressions or something? all i need is to know how to get Mozilla to return true, and Netscape to return false...
Just search through looking for the string "Netscape":
PHP Code:
<?PHP
$browser = $_SERVER["HTTP_USER_AGENT"];
if (preg_match("/Netscape/",$browser)) {
echo "The browser is Netscape";
}
else {
echo "The browser is not Netscape";
}
?>
hey thanx, i guess i just didnt think of it that way...i was thinking of differences between the two, when all i needed was the fact that it wasnt one, so it was the other...
Bookmarks