php if mobile 1

php if mobile

function isMobile() {
    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"]);
}

Here is what the above code is Doing:
1. It checks if the user agent is a mobile device.
2. If it is, it redirects to the mobile version of the site.
3. If it isn’t, it redirects to the desktop version of the site.

Similar Posts