Skip to content

Instantly share code, notes, and snippets.

@benmay

benmay/mysite_is_mobile..php Secret

Created May 21, 2013
Embed
What would you like to do?
<?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
You can’t perform that action at this time.