Detect whether device is mobile or desktop

Detect whether device is mobile or desktop

Sometimes happens that you want to add design and structure different for the mobile and different for the desktop and every time you can’t use media query and move the structure or design because if sometimes get complicated for that you need to add below given PHP code

function isMobileDevice() {

return preg_match("/(ipad|iphone|ipod|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()){

code for mobile

}

else

{

Code for desktop

}

?>



Copyright © 2024 Tridhya Tech Limited, Inc. All rights reserved.