Now all web projects have a desktop version site as well as mobile version site. When the visitors visit your website from a mobile device, they need to be redirected to the mobile website. We have made a simple user agent class for detect mobile devices and tablets in PHP. Also you would be able to redirect mobile users to the mobile site with our user agent class.
The user agent class is simple PHP class which helps to mobile device detection. You should call a method from this class to check if visitors visit your site from mobile devices or tablets or desktop and you can redirect visitor to the suitable website.
You only need to download two files from below.
user_agents_config.php file contains all the user agents and
user_agent.php file contain
UserAgent class. Also note that, those two files should insert at the same directory.
At first you will need to include the
user_agents_config.php file and create an instance of
UserAgent class. Now just call the
is_mobile() function for checking if the visitors from mobile devices.
is_mobile() function return
TRUE if the visitors from mobile devices, otherwise return
//create an instance of UserAgent class
$ua = new UserAgent();
//if site is accessed from mobile, then redirect to the mobile site.
You can place the above PHP code to the beginning of the landing page at your desktop version website.
Are you want to get implementation help, or modify or extend the functionality of this script? Submit paid service request