Home | Services | Portfolio | Resources | About

MobileESP Demo: PHP

This web page is designed to demonstrate how the PHP version of the MobileESP code works with your mobile device.

MobileESP is free, open source and lightweight code for detecting mobile device visitors to web sites. For more information about the MobileESP project, visit the official web site: www.MobileESP.org

MobileESP has a simple API for detecting mobile devices. The API returns the simple Boolean result of TRUE if the device is the specified type, or FALSE if it isn't. For more information about the PHP version of the API, please visit the MobileESP API page on the project web site.

Page Index

Device Tiers | Basic Detection | Global Info | Apple iOS | Android & GoogleTV Windows | BlackBerry | Symbian | Palm | Other Phones & Devices | Specific Browsers | Smart TVs | Gaming Consoles | Device Capabilities | Quick Variables | Notes

 

Device Tiers

These methods group mobile phones into three broad tiers based on the capabilities of their browsers.

  • DetectTierTablet(): These devices generally have larger screens (8 inches or larger) and their browsers are HTML 5-capable. These browsers handle CSS and JavaScript very well, which means that modest AJAX sites with native (iPad or other) style components typically work great. Includes: iPad, Android tablets (e.g., Xoom, Samsung Galaxy Tab 10.1), BlackBerry PlayBook, etc. Interestingly, Google's Nexus 7 tablet reports itself in this category. *This list will be updated as new tablets are launched!
    • Value found: false
  • DetectTierIphone(): These are modern touchscreen phones with WebKit browsers. These browsers handle CSS and JavaScript very well, which means that modest AJAX sites with native (iPhone or other) style components typically work great. When testing for this tier, include at least 3 platforms to be sure the app works great and isn't an "iPhone-only" site. Includes: iPhone and iPod Touch, Android, Windows 8, BlackBerry OS 6 & 10, Palm WebOS, Playstation Vita, etc. Note that many 7" tablets report themselves as multi-media players and would show up here.
    • Value found: false
  • DetectTierRichCss(): These devices can handle CSS reasonable well, so that iPhone- or Android-style UIs generally look fine. Unfortunately, JavaScript support is poor. For these reasons, in most cases, it's probably best to serve these devices the generic mobile site rather than the iPhone Tier site. Includes: Symbian S60 Open Source Browser, 'High' BlackBerry Devices, Windows Mobile, other Webkit-based devices.
    • Value found: false
  • DetectTierOtherPhones(): Detects for all other mobile devices, with an emphasis on feature phones. For these devices, it’s best to serve only the most basic styling, limited to little more than text color, alignment, and bold/italics. JavaScript support is virtually non-existent for these devices.
    • Value found: false


Page Index

 

Basic Detection

  • DetectMobileQuick(): Will probably detect most recent/current mid-tier Feature Phones as well as smartphone-class devices. Excludes Apple iPads. Use this method when you don't care about the device's capabilities -- just whether it's a mobile device or not.
    • Value found: false
  • DetectMobileLong(): The longer and more thorough way to detect for a mobile device. Includes older and more obscure feature phones, older Internet Tablets, Internet-enabled game consoles, etc.
    • Value found: false
  • DetectSmartphone(): Detects any device in the 'smartphone' category -- including devices with less capable browers and older smartphones. As a result, to build a modern touch-optimized mobile site, use the DetectTierIphone() method instead.
    • Value found: false


Page Index

 

Global Info

  • Get_Uagent(): Returns the useragent string. For PHP, Java, and JavaScript, this value is lowercase. For ASP.NET, the value is uppercase. The spelling of the method varies by platform.
    • ccbot/2.0 (http://commoncrawl.org/faq/)
  • Get_HttpAccept(): Gets the full HTTP accept value. Browsers use this value to provide details about what kinds of content it can accept, such as images (e.g., PNG, GIF, JPG), text, and Java. This value is useful to detect for WAP and WML support in older devices.
    • Value found: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8


Page Index

 

Apple iOS Devices

  • DetectIphoneOrIpod(): Use this method when creating an iPhone-optimized site. We don’t want to ignore the iPod Touches!
    • Value found: false
  • DetectIphone(): Detects only iPhones.
    • Value found: false
  • DetectIpod(): Detects only iPod Touches.
    • Value found: false
  • DetectIpad(): Detects only iPads.
    • Value found: false
  • DetectIos(): A convenience method for detecting any iOS device: iPhone, iPod Touch, or iPad.
    • Value found: false


Page Index

 

Android & GoogleTV

  • DetectAndroid(): Detects any Android-powered device, including phones, multi-media players (e.g., Samsung Galaxy Player), tablets, and Google TV. Use this method for general Android detection.
    • Value found: false
  • DetectAndroidPhone(): Detects the generally small-ish Android devices which are intended to be phones or multi-media players. This function follows Google guidelines of looking for 'Android' and the word 'mobile'. Many 7" tablets report themselves as multi-media players, too, which is fine. Examples: Samsung Galaxy Tab (7") and Player; HTC Flyer (7").
    • Value found: false
  • DetectAndroidTablet(): Detects (self-reported) tablets, which generally run Honeycomb or later. This function simply follows Google guidelines of looking for 'Android' without the word 'mobile'. Examples: Nexus 7 tablet, Motorola Xoom, Samsung Galaxy Tab 10.1, etc.
    • Value found: false
  • DetectAndroidWebKit(): Detects any WebKit-based browser on an Android-powered device.
    • Value found: false


Page Index

 

Windows Devices

  • DetectWindowsPhone(): The generic detection method for Windows Phone 7, 8, and 10. In most cases, use this detection method rather than either the version-specific methods.
    • Value found: false
  • DetectWindowsPhone10(): Detects devices powered by the new Windows Phone 10 OS. A modern HTML5 browser.
    • Value found: false
  • DetectWindowsPhone8(): Detects devices powered by Windows Phone 8. This OS's browser generally handles both desktop and iPhone Tier web sites pretty well. (It's based on IE 10.)
    • Value found: false
  • DetectWindowsPhone7(): Detects devices powered by the Windows Phone 7.x OS. This OS's browser generally handles desktop web pages well, but has difficulty with iPhone Tier web sites.
    • Value found: false
  • DetectWindowsMobile(): Detects older Windows Mobile devices, which had virtually no CSS or JavaScript support. Includes both Windows Mobile PocketPC/Professional and WM Smartphone/Standard.
    • Value found: false


Page Index

 

BlackBerry Devices

This section is a little complicated because BlackBerry's browser was extremely poor before OS 6. The BlackBerry's browser had fragmented capabilities across devices on the market at the same time.

  • DetectBlackBerry(): Detects any BlackBerry device, including both the new BB10 OS devices and the older devices with the extremely poor browsers. Excludes the PlayBook.
    • Value found: false
  • DetectBlackBerry10Phone(): Detects a device running the new BB10 OS.
    • Value found: false
  • DetectBlackBerryWebKit(): Detects any BlackBerry device running the newer Webkit-based browser. These are BB OS 6 or later devices and the PlayBook. Use this method for detecting the modern devices.
    • Value found: false
  • DetectBlackBerryTablet(): Detects the BlackBerry PlayBook tablet.
    • Value found: false
  • DetectBlackBerryTouch(): Detects touchscreen BlackBerry phones, including the Storm 1 and 2 (OS 5), Torch (OS 6), and later phones.
    • Value found: false
  • DetectBlackBerryHigh(): This method was created to detect devices which could display mobile CSS moderately well even though JavaScrip support was extremely poor. Examples: Storm, Bold, Tour, Curve2.
    • Value found: false
  • DetectBlackBerryLow(): This method was created to detect older devices which can't reliable display mobile CSS nor handle JavaScript. Examples: Pearl, Curve, 8800.
    • Value found: false


Page Index

 

Nokia & Symbian Devices

  • DetectS60OssBrowser(): Detects any Symbian-powered device powered by the newer Webkit-based open source browser. Use this method for general Symbian detection.
    • Value found: false
  • DetectSymbianOS(): Detects any Symbian-based device, including the older devices from Nokia (S60), Sony Ericsson (UIQ), Motorola (UIQ), and others.
    • Value found: false


Page Index

 

Palm Devices

  • DetectPalmWebOS(): Detects phone devices powered by HP/Palm WebOS, such as the Pre, Veer, etc. Use this method for detecting the modern devices.
    • Value found: false
  • DetectWebOSTablet(): Detects tablet devices powered by HP/Palm WebOS, such as the HP TouchPad.
    • Value found: false
  • DetectPalmOS(): Detects older Palm OS devices, which had virtually no CSS or JavaScript support.
    • Value found: false


Page Index

 

Other Phones & Devices

  • DetectKindle(): Detects Amazon Kindle e-Reader devices. (Kindle Fire tablets detect TRUE as Android devices.)
    • Value found: false
  • DetectBada(): Detects devices running Samsung's Bada OS. (Samsung's alternative smartphone OS through 2012.)
    • Value found: false
  • DetectTizen(): Detects devices running Tizen OS. Tizen is a joint effort by Intel and Samsung, building off the legacy Meego and Bada platforms.
    • Value found: false
  • DetectMeego(): Detects Meego OS devices.
    • Value found: false
  • DetectMeegoPhone(): Specifically detects a phone running Meego OS.
    • Value found: false
  • DetectFirefoxOS(): Detects a mobile device (probably) running the Firefox OS. (Firefox don't differentiate between Firefox OS and their browser running on other mobile platforms.)
    • Value found: false
  • DetectFirefoxOSPhone(): Detects a phone (probably) running the Firefox OS.
    • Value found: false
  • DetectFirefoxOSTablet(): Detects a tablet (probably) running the Firefox OS.
    • Value found: false
  • DetectSailfish(): Detects a mobile device running the Sailfish OS.
    • Value found: false
  • DetectSailfishPhone(): Detects a phone running the Sailfish OS.
    • Value found: false
  • DetectUbuntu(): Detects a mobile device running the Ubuntu Mobile OS.
    • Value found: false
  • DetectUbuntuPhone(): Detects a phone running the Ubuntu Mobile OS.
    • Value found: false
  • DetectUbuntuTablet(): Detects a tablet running the Ubuntu Mobile OS.
    • Value found: false
  • DetectMaemoTablet(): Detects Nokia's old Maemo OS-based Internet tablet devices.
    • Value found: false
  • DetectDangerHiptop(): Detects Danger Hiptop devices.
    • Value found: false
  • DetectGarminNuvifone(): Detects Nuvifone devices from Garmin.
    • Value found: false
  • DetectSonyMylo(): Detects old Sony Mylo Internet tablets.
    • Value found: false
  • DetectArchos(): Intended to detect older Archos media & Internet tablets before they adopted Android.
    • Value found: false


Page Index

 

Detecting Specific Browsers

  • DetectWebkit(): Detects any Webkit-based browser whether mobile or desktop, including Apple's desktop Safari and Google's Chrome browsers.
    • Value found: false
  • DetectOperaMobile(): Detects one of the mobile-optimized Opera browsers, either Opera Mobile or Mini.
    • Value found: false


Page Index

 

Detecting Smart TVs

  • DetectTizenTV(): Detect a smart TV running the Tizen OS. (Typically from Samsung.)
    • Value found: false
  • DetectWebOSTV(): Detects a smart TV running WebOS. (Typically from LG.)
    • Value found: false
  • DetectGoogleTV(): Detects Google TV devices. (Google TV pre-dates Android TV.)
    • Value found: false


Page Index

 

Game Consoles

  • DetectGameConsole(): A single method to detect all supported game consoles.
    • Value found: false
  • DetectGamingHandheld(): Detects handheld touchscreen gaming devices with modern capable browsers. For example, the Sony Playstation Vita. Currently excludes iPod Touch devices.
    • Value found: false
  • DetectXbox(): Detects Microsoft Xboxes.
    • Value found: false
  • DetectNintendo(): Detects Nintendos.
    • Value found: false
  • DetectSonyPlaystation(): Detects Sony Playstations, including both consoles and handeld units.
    • Value found: false


Page Index

 

Detecting Device Capabilities

  • DetectBrewDevice(): Detects any Qualcomm Brew OS-powered device. This is a common feature phone OS on some carriers, especially Verizon in the U.S.
    • Value found: false
  • DetectWapWml(): Detects whether the device is capable of viewing WAP WML-formatted Web pages. This feature is more common among feature phones.
    • Value found: false
  • DetectMidpCapable(): Detects whether the device is capable of installing Mobile Java (J2ME) apps. This feature is more common among feature phones.
    • Value found: false


Page Index

 

Quick Variables

We've added a few variables to speed up processing for commonly used detection queries. These variables are initialized by the Constructor. Feel free to take advantage of them, as well!

  • isIphone: Whether the device is an iPhone ONLY -- it ignores iPod Touches. Stores the result of DetectIphone().
    • Value found: false
  • isAndroid: Whether the device is ANY Android device. Stores the result of DetectAndroid().
    • Value found: false
  • isAndroidPhone: Whether the device is an Android phone or media player (generally 7" or less). Stores the result of DetectAndroidPhone().
    • Value found: false
  • isWebkit: Whether the browser is WebKit-based on ANY type of device (mobile, laptop, PC, etc.). Stores the result of DetectWebkit().
    • Value found: false
  • isMobilePhone: Whether the device is ANY mobile phone (excludes tablets). Stores the result of DetectMobileQuick().
    • Value found: false
  • isTierTablet: Whether the tablet is a modern touch-optimized OS with a mobile heritage. (iPad yes, Windows 8 no.) Stores the result of DetectTierTablet().
    • Value found: false
  • isTierIphone: Whether the device is in the iPhone tier. Stores the result of DetectTierIphone().
    • Value found: false
  • isTierRichCss: Whether the device can probably support basic CSS, but neither JavaScript support nor a touchscreen are assumed. Stores the result of DetectTierRichCss().
    • Value found: false
  • isTierGenericMobile: Whether it is another mobile device, which cannot be assumed to support CSS or JS. Stores the result of DetectTierOtherPhones().
    • Value found: false


Page Index

 

Important Notes

Testing: We've casually tested this code on all of the major smartphone platforms and a handful of mass market phones, plus the Nokia Internet Tablets. So far so good! That being said, the most important caveat is that you should thoroughly test the code for yourself based on your own needs and expectations -- and always using your high priority target devices!

Licensing & Costs: MobileESP uses Apache License 2.0 and is free to use. For more info, please visit the new MobileESP site: www.mobileESP.org

Alternatives:MobileESP is a lightweight and easily customizable device detection library. For more robust features, you may wish to consider WURFL or HandsetDetection.com.

Donations:If you like and use this code, please consider donating. Any amount is appreciated! (Donations help us purchase additional devices on our testing wishlist!)


Page Index