All for Joomla The Word of Web Design

Detect device type in php

Today, We are going to learn how to detect user device type in the php. there are many code conditions when we want to use some specific code for some specific device. In these conditions we can easily manage our code if we can detect the users device type.Some users requested me to create this post. With the help of this post we can easily detect the users device type. it is very easy to detect the users device type. We need to create a array of $_SERVER[“HTTP_USER_AGENT”] responses and a simple loop to to match the uesrs current response . Working of the code is written below and explained. With the help of this code we can detect the following device:

  • Mobile,
  • Tablet,
  • Computer,
  • Bot

We can detect the device with the help of $_SERVER[“HTTP_USER_AGENT”];

let’s create an array of the list of devices and browsers type:

Let’s Create a function to detect device type

Our code is Complete

Run our code

I hope this Code will help you. If you like this post please share and like our facebook page.


1 Comment

  • Rahul Reply

    December 4, 2017 at 8:02 pm

    Really helpful,thanks

Leave a Comment


Welcome! Login in to your account

Remember me Lost your password?

Lost Password