Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect device to show model of mobile?

Tags:

php

In a website, how to detect device => model name of mobile when using mobile ? How to ideas

like image 238
user1494997 Avatar asked Nov 03 '22 21:11

user1494997


2 Answers

Use: $_SERVER['HTTP_USER_AGENT'];

You can read more about $_SERVER calls here

like image 61
Nir Alfasi Avatar answered Nov 12 '22 13:11

Nir Alfasi


Although you can directly use the $_SERVER variable, there is a small PHP library called Mobile_Detect.php that makes your files very clean.

I think it runs through the $_SERVER variable, anyways, but it looks nicer to just call is_iPhone() than to parse through the header and possibly miss something.

like image 31
Jon Egeland Avatar answered Nov 12 '22 13:11

Jon Egeland