Here is the presentation on device detection that I gave to Nick Bilton's "1 2 10" class at NYU IPT:
Device Detection Presentation [pdf]
Here is a simple example using a PHP library to detect if a browser (user-agent) is mobile or not:
<?php
include("mobile_device_detect.php");
if (mobile_device_detect()) {
print "im a mobile device";
} else {
print "nope - im not a mobile device";
}
?>
Here is an example using the WURFL Device Database to detect mobile devices and print out the device capabilities:
mkdir data/ mv wurfl.xml data/ chmod 777 data/
define("DATADIR", './data/');
<?php
require_once('./wurfl_config.php');
require_once(WURFL_CLASS_FILE);
// creating the WURFL object
$device = new wurfl_class($wurfl, $wurfl_agents);
$device->GetDeviceCapabilitiesFromAgent($_SERVER["HTTP_USER_AGENT"]);
if ($device->browser_is_wap ) {
print "yep - is a mobile device";
// print out device info
print "<pre>";
print_r($device->capabilities);
print "</pre>";
} else {
print "nope - is not a mobile device";
}
?>
Firefox User-Agent Swicher
Simple PHP Mobile Detection
WURFL - Device Database
Tera-WURFL - a WURFL-based device detection library
Device Atlas - Another device detection service/library
Michael - myoung [at] 81nassau.com