Depending on each ones needs, we often need ways to detect if our visitors are using an iPad, a smartphone or any other mobile device in order to make out website responsive and even faster by reducing data load. The following are a bunch of classes and snippets you can use to accomplish that, either on the back-end (server side) or on the front-end (client side), depending on each development situation, making it easier to detect mobile devices.
Mobile Detect is a lightweight PHP class for detecting mobile devices (including tablets). It uses the User-Agent string combined with specific HTTP headers to detect the mobile environment.
You may consider this script as being part of the RESS (Responsive Web Design with Server-Side Component) movement. You can find out more on the topic by reading these articles: Improve Mobile Support With Server-Side-Enhanced Responsive Design and RESS: Responsive Design + Server Side Components.