Created
September 8, 2024 07:03
-
-
Save serverok/03d39aa0fcdabb24ac4df0e8006a7477 to your computer and use it in GitHub Desktop.
PHP function to identify Mobile Users
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
function is_mobile() | |
{ | |
if (empty($_SERVER["HTTP_USER_AGENT"])) { | |
return false; | |
} | |
return @preg_match("/(android|webos|avantgo|iphone|ipad|ipod|blackberry|iemobile|bolt|boost|cricket|docomo|fone|hiptop|mini|opera mini|kitkat|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", ''.$_SERVER["HTTP_USER_AGENT"]); | |
} | |
function is_iphone() | |
{ | |
if (empty($_SERVER["HTTP_USER_AGENT"])) { | |
return false; | |
} | |
return @preg_match("/(iphone|ipod)/i", ''.$_SERVER["HTTP_USER_AGENT"]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment