Forum Moderators: coopster
<?php
$useragent = (isset($_SERVER["HTTP_USER_AGENT"]) )?
$_SERVER["HTTP_USER_AGENT"] : $HTTP_USER_AGENT;
if (strpos($useragent, 'MSIE')) {
$css_file = '/style_ie.css';
} else {
$css_file = '/style.css';
}
?>
But now I want to be able to determine the difference not only between IE and other browsers but also Mac and PC. The above script will only recognize a single word as the string. (does this make sense?)
For instance, here's the results from my computer running the above script:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)
and on a friend's MAC it's:
Mozilla/4.0 (compatible; MSIE 5.23; Mac_PowerPC)
It seems I wold need to select both the 'MSIE' part and the 'Windows' or 'Mac_PowerPC' part from the script to select the style sheet.
Does anyone know how to write a script to select both parts of the ($_SERVER["HTTP_USER_AGENT"]) result? Have I even made sense here?