Web Design

Google

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;
}
}

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

You must be logged in to post a comment.




Web Design World