Web Design – Domain Name – Making Money

July 25, 2008

Detecting if user-agent corresponds to mobile phone

Filed under: Web Design — admin @ 10:00 am

I’m now using this code that should detect properly most mobile brands:
/* Return TRUE if user is using mobile phone browser */
function ismobile(){
$useragent = $_SERVER['HTTP_USER_AGENT'];
// Standard vendor-model/version user agents
if (preg_match(‘/^((ACERlcatelUDIOVOXlackBerryDMricssonG\bGEotorolaOTECokiaanasonicCIAGEMAMSUNGECanyoendoHARPIEonyEricssonelitelit_mobile_TerminalsSM)[- ]?([^\/\s\_]+))(\/(\S+))?/’, $useragent)){
return true;
}else{
return false;
}
}

Copyright: 2005 - 2011, Web Design World, Powered by: Medical Supply Company & Modern Medical