//Detect special conditions devices
$iPod = stripos($_SERVER['HTTP_USER_AGENT'],"iPod");
$iPhone = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$iPad = stripos($_SERVER['HTTP_USER_AGENT'],"iPad");
if(stripos($_SERVER['HTTP_USER_AGENT'],"Android") && stripos($_SERVER['HTTP_USER_AGENT'],"mobile")){
$Android = true;
}else if(stripos($_SERVER['HTTP_USER_AGENT'],"Android")){
$Android = false;
$AndroidTablet = true;
}else{
$Android = false;
$AndroidTablet = false;
}
$webOS = stripos($_SERVER['HTTP_USER_AGENT'],"webOS");
$BlackBerry = stripos($_SERVER['HTTP_USER_AGENT'],"BlackBerry");
$RimTablet= stripos($_SERVER['HTTP_USER_AGENT'],"RIM Tablet");
//do something with this information
if( $iPod || $iPhone ){
//were an iPhone/iPod touch -- do something here
}else if($iPad){
//were an iPad -- do something here
}else if($Android){
//were an Android Phone -- do something here
}else if($AndroidTablet){
//were an Android Phone -- do something here
}else if($webOS){
//were a webOS device -- do something here
}else if($BlackBerry){
//were a BlackBerry phone -- do something here
}else if($RimTablet){
//were a RIM/BlackBerry Tablet -- do something here
}
If you would like information on how to detect a device other than those supported above, feel free to contact me.
Update (9-14-2011): Added BlackBerry & Playbook detection.
Update (9-6-2011): Split Android detection to differentiate between Tablets & Phones.









Feb 4th, 2012 at 11:22 am
Hello, to detect BBerries and playbook table we’d be talking about something like that:
$blackberry = stripos($_SERVER['HTTP_USER_AGENT'],”blackberry”);
or is there any other thing required?
Many thanks for your solution!
[Reply]
Chris Schiffner Reply:
February 4th, 2012 at 11:22 am
I’ll look up the BlackBerry and Playbook user agents tomorrow and update the code to add support.
[Reply]
Chris Schiffner Reply:
February 4th, 2012 at 11:23 am
I’ve updated the example above to detect BlackBerry’s and Playbooks. Hope it helps!
[Reply]
Douglas Reply:
February 4th, 2012 at 11:23 am
Thanks Chris for your contribution, great work!
[Reply]