How to get a mobile, ipad or tablet model

I want to get a mobile model, for example iPhone 3G or 3GS, Nokia 9231, iPad Mini, Samsung 10.1 tablet, etc.

I used

$_SERVER['HTTP_USER_AGENT']

but he brings me back

Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:26.0) Gecko/20100101 Firefox/26.0

I also used the Mobile Detect class, it only tells me the version of the operating system, but does not tell me the device model?

Is it possible how?

+3
source share
1 answer

I don't know if you need to do this in php. But there is an easy way to do this in javascript.

alert(navigator.userAgent);

And you can do things like:

if(/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent)) {
    //Change some css or something like that
}
-1
source

All Articles