-
-
Save SeanJA/433283 to your computer and use it in GitHub Desktop.
mobile browser detection
This file contains hidden or 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 | |
$mobiles = array( | |
'iphone','ipod','android','blackberry',//and so on | |
); | |
$agent = strtolower($_SERVER['HTTP_USER_AGENT']); | |
if($match = preg_match('/('.implode('|',$mobiles).')/', $agent)){ | |
echo 'mobile'; | |
//include mobile stuff here | |
} else { | |
echo 'not mobile'; | |
//do normal stuffs | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Right... erm... I meant that...