Detecting mobile devices?
Posted: Wed Nov 21, 2012 3:41 pm
Like many others, I too am trying to provide different layouts/views for mobile devices for my website. I've tried the methods used here:
http://www.i-do-this.com/blog/14/Make-y ... bile-ready
Unfortunately, I'm not having much success. I can see the PHP in the example function is using the HTTP_USER_AGENT value to determine what mobile device is being used.
The value I'm seeing when I open up a site on my Android phone for the HTTP_USER_AGENT value is:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:15.0) Gecko/20100101 Firefox/15.0
I don't see "android" anywhere in that string... this leads me to believe using HTTP_USER_AGENT is a poor way to determine if my site is being displayed on Android.
Is there a better or more correct (and dependable) way to determine if your site is being displayed on a mobile device?
I'm using CMSMS 1.10.2.
http://www.i-do-this.com/blog/14/Make-y ... bile-ready
Unfortunately, I'm not having much success. I can see the PHP in the example function is using the HTTP_USER_AGENT value to determine what mobile device is being used.
Code: Select all
...
$user_agent = $_SERVER['HTTP_USER_AGENT'];
...
case (eregi('android',$user_agent));
$mobile_browser = $android;
...
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:15.0) Gecko/20100101 Firefox/15.0
I don't see "android" anywhere in that string... this leads me to believe using HTTP_USER_AGENT is a poor way to determine if my site is being displayed on Android.
Is there a better or more correct (and dependable) way to determine if your site is being displayed on a mobile device?
I'm using CMSMS 1.10.2.