4

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

James Goodwin
  • 7,360
  • 5
  • 29
  • 41
Yogi Yang 007
  • 5,147
  • 10
  • 56
  • 77
  • 2
    Before asking, please search. http://stackoverflow.com/questions/142273/standard-way-to-detect-mobile-browsers-in-a-web-application-based-on-the-http-req. This is a duplicate. – S.Lott Apr 10 '10 at 11:34

4 Answers4

5

you should check the user-agent header which is sent along the HTTP request. Since there are so many useragents, it's really difficult to recognize the various devices/platforms. For this purpose there is a freeware library which can help out : wurfl

Basically it maps the user-agent to a device object which you can query for it's capabilities. This way in your layout you can take advantage of the device's screenwidth/height, what image formats it supports, etc

Toad
  • 15,593
  • 16
  • 82
  • 128
5

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";
}
?>    
Steve Kamerman
  • 146
  • 1
  • 1
1

http://beradrian.wordpress.com/2008/10/10/mobile-device-recognition/

Jim Blackler
  • 22,946
  • 12
  • 85
  • 101
1

We sometimes use Apache rewrite rules when a client wants to divert traffic before it reaches our server.

See http://www.bemoko.com//training.team/help/team/pc-to-mobile-redirect for more information.

Mat Diss
  • 11
  • 2