Return to Snippet

Revision: 43775
at March 30, 2011 22:08 by shodan_uk


Initial Code
if (!defined('REQUEST_MOBILE_UA')) {
  define('REQUEST_MOBILE_UA', '(iPhone|Android|MIDP|AvantGo|BlackBerry|J2ME|Opera Mini|DoCoMo|NetFront|Nokia|PalmOS|PalmSource|portalmmm|Plucker|ReqwirelessWeb|SonyEricsson|Symbian|UP\.Browser|Windows CE|Xiino)');
}

function isMobile() {
  preg_match('/' . REQUEST_MOBILE_UA . '/i', $_SERVER['HTTP_USER_AGENT'], $match);
  if (!empty($match)) {
    return true;
  }
  return false;
}

Initial URL

                                

Initial Description
Adapted from CakePHP

Initial Title
Check useragent for mobile device

Initial Tags
mobile

Initial Language
PHP