Skip to content

Instantly share code, notes, and snippets.

@alicanatas
Created October 1, 2018 10:15
Show Gist options
  • Save alicanatas/335dfeb962675ec23b8b3734c5bacaf0 to your computer and use it in GitHub Desktop.
Save alicanatas/335dfeb962675ec23b8b3734c5bacaf0 to your computer and use it in GitHub Desktop.
PHP get device IOS / ANDROID or PC
function user_agent(){
$iPod = strpos($_SERVER['HTTP_USER_AGENT'],"iPod");
$iPhone = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$iPad = strpos($_SERVER['HTTP_USER_AGENT'],"iPad");
$android = strpos($_SERVER['HTTP_USER_AGENT'],"Android");
file_put_contents('./public/upload/install_log/agent',$_SERVER['HTTP_USER_AGENT']);
if($iPad||$iPhone||$iPod){
return 'ios';
}else if($android){
return 'android';
}else{
return 'pc';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment