Luno1599
19-03-2008, 05:23 PM
Hey,
I own a site its fine for people on PC/Mac but.... When I look on it on my iTouch its wierd so I wanted my index page to find out that its an iphone/itouch and redirect to another page... but how do i make it know thats its an iphone/itouch?
I have this code:
<?php
$useragent = $_SERVER['HTTP_USER_AGENT'];
if (preg_match("|MSIE ([0-9].[0-9]{1,2})|",$useragent,$matched)) {
$browser_version=$matched[1];
$browser = "IE";
} else if (preg_match("|Opera ([0-9].[0-9]{1,2})|",$useragent,$matched)) {
$browser_version=$matched[1];
$browser = ‘Opera’;
} else if(preg_match("|Firefox/([0-9\.]+)|",$useragent,$matched)) {
$browser_version=$matched[1];
$browser = "Firefox";
} else if(preg_match("|Safari/([0-9\.]+)|",$useragent,$matched)) {
$browser_version=$matched[1];
$browser = "Safari";
} else {
// browser not recognized!
$browser_version = 0;
$browser= "other";
}
print "browser: $browser";
?>
and the iTouch safariis like this...
Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/4A102 Safari/419.3
Dan
I own a site its fine for people on PC/Mac but.... When I look on it on my iTouch its wierd so I wanted my index page to find out that its an iphone/itouch and redirect to another page... but how do i make it know thats its an iphone/itouch?
I have this code:
<?php
$useragent = $_SERVER['HTTP_USER_AGENT'];
if (preg_match("|MSIE ([0-9].[0-9]{1,2})|",$useragent,$matched)) {
$browser_version=$matched[1];
$browser = "IE";
} else if (preg_match("|Opera ([0-9].[0-9]{1,2})|",$useragent,$matched)) {
$browser_version=$matched[1];
$browser = ‘Opera’;
} else if(preg_match("|Firefox/([0-9\.]+)|",$useragent,$matched)) {
$browser_version=$matched[1];
$browser = "Firefox";
} else if(preg_match("|Safari/([0-9\.]+)|",$useragent,$matched)) {
$browser_version=$matched[1];
$browser = "Safari";
} else {
// browser not recognized!
$browser_version = 0;
$browser= "other";
}
print "browser: $browser";
?>
and the iTouch safariis like this...
Mozilla/5.0 (iPod; U; CPU like Mac OS X; en) AppleWebKit/420.1 (KHTML, like Gecko) Version/3.0 Mobile/4A102 Safari/419.3
Dan