Created
October 1, 2018 10:15
-
-
Save alicanatas/335dfeb962675ec23b8b3734c5bacaf0 to your computer and use it in GitHub Desktop.
PHP get device IOS / ANDROID or PC
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
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