Skip to content

Instantly share code, notes, and snippets.

@Soullighter
Created August 29, 2023 11:14
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 Soullighter/dbca179d00a7b5c04d94d785de44e628 to your computer and use it in GitHub Desktop.
Save Soullighter/dbca179d00a7b5c04d94d785de44e628 to your computer and use it in GitHub Desktop.
Check UserAgent if it's mobile in PHP
function isMobileDevice2() {
return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]);
}
if( isMobileDevice2() === 1 || isMobileDevice2() === false) {
// Magic
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment