Mobile detection in php

Hi all

How can I detect mobile web browser and desktop web browser separately ?
what I am looking how to detect mobile phones by using php ? Can any done this kind of technique ?

please help me
Thanks

get_browser will retrieve information like this
Mozilla/5.0 (Linux; U; Android 1.5; en-us; A6277 Build/CUPCAKE) AppleWebKit/528.5+ (KHTML, like Geck

that’s from my Android phone.

The Class file i useful because it grabs all that information and strips the names of the phones; so as for maintaining a list sorta. You have to let the class file know of any new platform; but you can just focus on the main ones Android, iPhone, etc…

If you have installed browcap.ini on your server you could use get_browser() to check if mobiledevice is set to ‘1’.

If not, you’ll need to manually evaluate the HTTP_USER_AGENT string, possibly using a class such as http://phpsniff.sourceforge.net/ to figure out if it’s a mobile device.

yeah… you grab what you need. Just use the class file it does all the dirty work for you.

Update:

I found this http://code.google.com/p/php-mobile-detect/downloads/list looks good.

Eh? get_browser() will return an array or object containing a whole bunch of seperate bits of data:


<?php
echo $_SERVER['HTTP_USER_AGENT'] . "\
\
";

$browser = get_browser(null, true);
print_r($browser);
?>


Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7) Gecko/20040803 Firefox/0.9.3

Array
(
    [browser_name_regex] => ^mozilla/5\\.0 (windows; .; windows nt 5\\.1; .*rv:.*) gecko/.* firefox/0\\.9.*$
    [browser_name_pattern] => Mozilla/5.0 (Windows; ?; Windows NT 5.1; *rv:*) Gecko/* Firefox/0.9*
    [parent] => Firefox 0.9
    [platform] => WinXP
    [browser] => Firefox
    [version] => 0.9
    [majorver] => 0
    [minorver] => 9
    [cssversion] => 2
    [frames] => 1
    [iframes] => 1
    [tables] => 1
    [cookies] => 1
    [backgroundsounds] =>
    [vbscript] =>
    [javascript] => 1
    [javaapplets] => 1
    [activexcontrols] =>
    [cdf] =>
    [aol] =>
    [beta] => 1
    [win16] =>
    [crawler] =>
    [stripper] =>
    [wap] =>
    [netclr] =>
)

Thanks
I am able to find the class.Can I use this to check the mobile browsers and desktop versions ?

No, if you use that class, you’ll need to maintain a list yourself of which browsers are mobile and which are desktop based.

The phpSniff class will only help you identify the client.