Get user device, browser, screen resolution etc in PHP 7.2

Hi All

Any help with this would be great… I want to save info about my users (not user specific) abotu what browser they are using, what sort of device they are using, their screen resolution etc so I know what to develop for and what to test in.

Any idea how I do that?

mrmbarnes

You can get the browser from the user agent string. For the screen resolution you’ll need JavaScript.

BTW PHP 7.2 is no longer supported and security fixes end at the end of the month.

1 Like

Trying to get browser info from the user agent is a pain but there are libraries that do a lot of the hard work. I’ve used MobileDetect before but it’s a bit out of date now. I’m sure there are others though.

You are probably better off getting this info from Analytics, or similar services. PHP isn’t great at getting client info, being server-side, it does not get a lot of fed back from the client.

In reality, you shouldn’t really think about things like specific screen sizes, develop for any screen size, (within reason).

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.