Created
December 16, 2013 17:05
-
-
Save ArupSen/7990438 to your computer and use it in GitHub Desktop.
PHP device sniffer. Do stuff on the server side.
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 | |
//Detect special conditions devices | |
$iPod = stripos($_SERVER['HTTP_USER_AGENT'],"iPod"); | |
$iPhone = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone"); | |
$iPad = stripos($_SERVER['HTTP_USER_AGENT'],"iPad"); | |
$Android = stripos($_SERVER['HTTP_USER_AGENT'],"Android"); | |
$webOS = stripos($_SERVER['HTTP_USER_AGENT'],"webOS"); | |
//do something with this information | |
if( $iPod || $iPhone ){ | |
//browser reported as an iPhone/iPod touch -- do something here | |
}else if($iPad){ | |
//browser reported as an iPad -- do something here | |
}else if($Android){ | |
//browser reported as an Android device -- do something here | |
}else if($webOS){ | |
//browser reported as a webOS device -- do something here | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment