Forum Moderators: coopster
Mozilla/4.0 (Compatible; MSIE 5.23; Mac_PowerPC)
A friend was trying to help me achieve this though it kept breaking the array. I need to match 'MSIE' and 'Mac' in the array string in order to have content served statically as IE on Mac does not support AJAX.
- John
Or, just write a regular expression and do a preg_match() [php.net].
And, I'm sure I've mentioned this to you before John, but as a reminder to anyone else reading this thread, Mac IE is dead [webmasterworld.com] and only certain niches still actively use it. So, before you decide to support it for your website, make sure your target market is using it. :)
This is how I process the array...
$checkit = '';
$answer = '';
foreach ($useragents['noajax'] as $ua) {
$checkit = stristr($useragent,$ua);
if ($checkit === false) {$answer = false;}
else
{$answer = true; break;}
}
- John
<?php
$useragent = 'Mozilla/4.0 (Compatible; MSIE 5.23; Mac_PowerPC)';
//$useragent = $_SERVER['HTTP_USER_AGENT'];
echo '<p>Checking UA: '.$useragent.'</p>';
$useragents['noajax'] = array('WebTV', 'CyberDog');
$answer = false;
foreach ($useragents['noajax'] as $ua) {
if (stristr($useragent,$ua) !== false) {
$answer = true; break;
}
}
if(!$answer && (strpos(strtolower($useragent), 'mac') !== false) && preg_match('/msie ([0-9]+)\.([0-9]+)/i', $useragent) != 0){
$answer = true;
}
echo '<p>'.(($answer)? 'No AJAX Support! Oh Noes!' : 'AJAX is in da\' house').'</p>';
?>