I’m trying to dynamically modify (server-side) the output of a page, whether the user is accessing it from a mobile device or not…
I’m using $user_agent, which gets me this, if I access the page from my Chrome on my laptop:
Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/536.10 (KHTML, like Gecko) Chrome/20.0.1123.4 Safari/536.10
I could ask if $user_agent contains MSIE or Mozilla or Windows or whatever (I’d appreciate a clever list for keywords)… but was just wondering if there was a better solution to this?
Thanks in advance.
There are tons of user agent strings out there for desktop browsers, when we are speaking about mobile devices it’s even worse.
I recommend you to use the WURFL library to check whether the actual devices are mobile or not, instead of building your own list.