<?php
function is_mobile_browser() {
$is_mobile = (bool) preg_match( '#\b(ip(hone|od)|android\b.+\bmobile|opera m(ob|in)i|windows (phone|ce)|blackberry' . '|s(ymbian|eries60|amsung)|p(alm|rofile/midp|laystation portable)|nokia|fennec|htc[\-_]' . '|up\.browser|[1-4][0-9]{2}x[1-4][0-9]{2})\b#i', $_SERVER['HTTP_USER_AGENT'] );
return $is_mobile;
}
if(is_mobile_browser())
{
echo "Site is running on Mobile";
}else
{
echo "Site is running on Desktop";
}
?>
Enjoy Code! Detect mobile browser using PHP
Hello Friends!
Hope you all are doing well! :)
If you want to check that your website is browsing in mobile phone and desktop OR want to add the any condition for mobile/desktop then use code given below :

