-
-
Save benmay/812149dee707828fdb73 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
<?php | |
function mysite_is_mobile() | |
{ | |
$isMobile = preg_match("#(ipod|iphone|android|opera mini|blackberry|pre/|palm os|palm|hiptop|avantgo|plucker|xiino|blazer|elaine|iris|3g_t|windows ce|opera mobi|windows ce; smartphone;|windows ce; iemobile)#i", $_SERVER['HTTP_USER_AGENT'] ); | |
// If an IP is X then show mobile (good for debugging m site) | |
// if( $_SERVER['REMOTE_ADDR'] == 'xxx.xxx.xxx.xxx' ) | |
// return true; | |
return $isMobile == 1 ? true : false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment