Despite of the awesome mobile browsers we have available nowadays, sometimes the best thing to do is to serve content at least mobile-optimized. But in order to do this you need to first detect which visitors are coming from mobile devices and which aren’t.
Today we’ll see a few ways to detect mobile browsers so you can chose the best suitable to your needs, and give your user the best experience possible.
#1 PHP User Agent
When the browser requests your server the page, it also sends some data about itself, like post data, referrer and the user agent. We could test the user agent comparing with a list of known mobile user agents so you can redirect the user to a different version, add a new cookie, set a global variable to be used in your CMS, set a HTML class or anything else you may want to do.Read More