Detecting if user-agent corresponds to mobile phone
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(’/^((ACERlcatelUDIOVOXlackBerryDMricssonG\bGEotorolaOTECokiaanasonicCIAGEMAMSUNGECanyoendoHARPIEonyEricssonelitelit_mobile_TerminalsSM)[- ]?([^\/\s\_]+))(\/(\S+))?/’, $useragent)){
return true;
}else{
return false;
}
}