Welcome folks today in this blog post we will be detecting website visitor mobile device and mobile browser
in php 7
. All the full source code of the application is shown below.
Get Started
In order to get started you need to make an index.php
file and copy paste the following code
index.php
<?php
function isMobileDevice() {
return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]);
}
if(isMobileDevice()){
echo "It is a mobile device";
}
else {
echo "It is desktop or computer device";
}
?>