I use getenv("HTTP_USER_AGENT") to determine between IE and other browsers. This works perfectly fine for a small site that I've put together. here's my code:
if (!ereg("MSIE", getenv("HTTP_USER_AGENT"))) {
$header = 'not_ie.php';
} else {
$header = 'ie.php';
}
include("$header");
Now I need to determine platform -- specifically I need to know when a Macintosh is accessing the site. I tried the following code
but when I pull up a page using a Mac (a new I-book w/ OS X if that makes a difference) apparently the script doesn't do the trick because I get "This ain't a Mac."
if (ereg("Mac", getenv("HTTP_USER_AGENT"))) {
echo ("This is a Mac.");
} else {
echo ("This ain't a Mac.");
}
There must be a better way to determine platform. Also, what I'm shooting for is to first determine whether or not the user is on a Mac, and then whether or not the user is using IE. Is there any particular concern this raises in writing my if/else statement?
Appreciate any help!