Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to recognize whether a web site is opened in a mobile or a PC

We have a site developed in PHP. It is working just fine. We have used JQuery for every kind of situation like slide shows, menus, etc.

This site contains a lot of images which are large in size. because of this when viewed in a mobile phone user has to scroll a lot.

How can we recognize whether the client (browser) trying to access our site is a mobile phone or a standard PC.

Is there any standard way to build site for such situations?

TIA

like image 368
Yogi Yang 007 Avatar asked Dec 18 '22 01:12

Yogi Yang 007


1 Answers

You should look at Tera-WURFL, it is a PHP & MySQL-based software package that detects mobile devices and their capabilities. Here is the Tera-WURFL code that you would use to detect if a request is coming from a mobile device:

<?php
require_once("TeraWurfl.php");
$wurflObj = new TeraWurfl();
$wurflObj->GetDeviceCapabilitiesFromAgent();
if($wurflObj->capabilities['product_info']['is_wireless_device']){
    echo "This is a mobile device";
}else{
    echo "This is a desktop browser";
}
?>    
like image 116
Steve Kamerman Avatar answered Dec 21 '22 09:12

Steve Kamerman