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

1

4 Answers 4

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"; } ?> 
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for this lib pointer. It did the trick in the way I wanted it to do.
is it only this signle script? because when I tried to find something, I just came across of some packs of PHP files...
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

Comments

1

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

1 Comment

Thanks for the link. I will check it out and get back if required.
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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.