Lightweight device-detection in PHP. One problem that keeps cropping up when developing mobile content is how to differentiate between mobile devices and desktop browsers.
We need to be able to do this before we can think about content adaptation. The "proper" way to do this is to use a full device detection database such as DeviceAtlas (see our tutorial here) but the following method may be sufficient to get you started. Update: We have an improved version of the algorithm which includes tablet detection here. This PHP code implements a mobile device detection algorithm that works for a good percentage of mobile browsers out there.
This code is the work of Andy Moore. Redirect a mobile/PDA to a "lite homepage" I've done it...
In ASP though, so you will have to look up the appropriate commands in PHP to do the same (easy). userAgent = Request.ServerVariables("HTTP_USER_AGENT") userAgent = lcase(userAgent) So basically you get the user agent from the client and parse the string... This works for everything I have so far, except for the ppc line, which I've seen a couple of glitches in...