Skip to content

Instantly share code, notes, and snippets.

@CrazyHackGUT
Created February 5, 2018 06:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CrazyHackGUT/631c2d819f2848748cf5b249117a3f27 to your computer and use it in GitHub Desktop.
Save CrazyHackGUT/631c2d819f2848748cf5b249117a3f27 to your computer and use it in GitHub Desktop.
// Original: https://gist.github.com/kythin/9775086
function isMobileDevice() {
$user_agent = strtolower ( $_SERVER['HTTP_USER_AGENT'] );
if ( preg_match ( "/phone|iphone|itouch|ipod|symbian|android|htc_|htc-|palmos|blackberry|opera mini|iemobile|windows ce|nokia|fennec|hiptop|kindle|mot |mot-|webos\/|samsung|sonyericsson|^sie-|nintendo/", $user_agent ) ) {
// these are the most common
return true;
} else if ( preg_match ( "/mobile|pda;|avantgo|eudoraweb|minimo|netfront|brew|teleca|lg;|lge |wap;| wap /", $user_agent ) ) {
// these are less common, and might not be worth checking
return true;
}
// this is not mobile device.
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment