Skip to content

Instantly share code, notes, and snippets.

@muks999
Forked from artikus11/getDeviceType
Created October 9, 2018 13:00
Show Gist options
  • Save muks999/5edf6e22ba15895cdb5edfc3a2729c34 to your computer and use it in GitHub Desktop.
Save muks999/5edf6e22ba15895cdb5edfc3a2729c34 to your computer and use it in GitHub Desktop.
Функция определения типа устройства
define("DEV_DEFAULT", 0);
define("ANDROID", 1);
define("IOS", 2);
function getDeviceType(){
$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
if(stripos($ua,'android') !== false) { return ANDROID; }
if(stripos($ua,'iPhone') !== false) { return IOS;}
if(stripos($ua,'iPad') !== false) { return IOS; }
return DEV_DEFAULT;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment