/ Published in: PHP
URL: http://www.phpdevblog.net/2009/01/detecting-mobile-devices.html
Expand |
Embed | Plain Text
class Client { /** * Available Mobile Clients * * @var array */ "midp", "240x320", "blackberry", "netfront", "nokia", "panasonic", "portalmmm", "sharp", "sie-", "sonyericsson", "symbian", "windows ce", "benq", "mda", "mot-", "opera mini", "philips", "pocket pc", "sagem", "samsung", "sda", "sgh-", "vodafone", "xda", "iphone", "android" ); /** * Check if client is a mobile client * * @param string $userAgent * @return boolean */ public function isMobileClient($userAgent) { foreach($this->_mobileClients as $mobileClient) { return true; } } return false; } } $client = new Client(); $client->isMobileClient($_SERVER['HTTP_USER_AGENT']);
Comments
Subscribe to comments
You need to login to post a comment.

Hi, there is a more sophisticated method to resolve mobile detection problem. It's call "Apache Mobile Filter", this filter allows you to access WURFL from any programming language, not just Java and php that is traditionally used for dynamic mobile web sites.
The module detects the mobile device and passes the WURFL capabilities on to the other web application as environment variables. It can also be used to resize images on the fly to adapt to the screen size of the mobile device.
For more info: http://www.idelfuschini.it/apache-mobile-filter-v2x.html