Created
February 5, 2018 06:43
-
-
Save CrazyHackGUT/631c2d819f2848748cf5b249117a3f27 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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