Welcome aboard! We are happy you are here and wish you good net-raft!
<!DOCTYPE html>
<html lang="en-US">
<head>
</head>
<body>
<?php
function GetDevice(){
$User_Agent = $_SERVER["HTTP_USER_AGENT"];
$Device_Types = array(
"COMPUTER" => array("trident", "msie 10", "msie 9", "msie 8", "edge", "windows.*firefox", "windows.*chrome", "x11.*chrome", "x11.*firefox", "macintosh.*chrome", "macintosh.*firefox", "opera", "safari"),
"TABLET" => array("tablet", "android", "ipad", "tablet.*firefox"),
"MOBILE" => array("mobile ", "android.*mobile", "iphone", "ipod", "opera mobi", "opera mini"),
"BOT" => array("googlebot", "mediapartners-google", "adsbot-google", "duckduckbot", "msnbot", "bingbot", "ask", "facebook", "yahoo", "addthis")
);
foreach($Device_Types as $deviceType => $My_Devices) {
foreach($My_Devices as $device) {
if(preg_match("/" . $device . "/i", $User_Agent)) {
$deviceName = $deviceType;
}
}
}
return ucfirst($deviceName);
}
?>
<?php
echo GetDevice()
?>
</body>
</html>
The most helpful PHP solutions