Tuesday, May 27, 2014

Detect Mobile Browser Using PHP

Sometimes we need to serve different looks and functions to users. As we know there so many people around the world using mobile phone to surf the net. I found this useful PHP class to detect user browser. I used this class in several projects.
It's called Browser.php
You can download the class on https://github.com/cbschuld/Browser.php

Installation
Simply include the Browser.php Class in your PHP file like this:
Inlcude('Browser.php');

Detecting Mobile Browser

Inlcude('Browser.php');
$Browser = new Browser();

if($Browser->isMobile()) { 
    // Contents for mobile browser
}
else { 
    // Contents for desktop browser
}

No comments :

Post a Comment