[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

What code can I write that senses whether my user is on a mobile phone as opposed to a desktop?

Posted on 2012-08-29
4
Medium Priority
?
363 Views
Last Modified: 2012-08-30
I am curious to know whether there's some script I can write that determines whether or not my user is attempting to access my site using a computer browser or a phone. In the event that they're using a phone, I'm wanting to redirect them to a more mobile friendly site.

Can it be done and if so, how?
0
Comment
Question by:brucegust
4 Comments
 
LVL 8

Assisted Solution

by:Ahmed Merghani
Ahmed Merghani earned 668 total points
ID: 38348838
You can use this class:
code.google.com/p/php-mobile-detect/
I think this is what you need.
0
 
LVL 36

Assisted Solution

by:Loganathan Natarajan
Loganathan Natarajan earned 664 total points
ID: 38348902
You could also try this script, http://detectmobilebrowsers.mobi/
0
 
LVL 34

Accepted Solution

by:
Beverley Portlock earned 668 total points
ID: 38349242
Depending on user agent strings can be hit and miss. A better way may be to look at CSS3 capabilities. Most mobile devices fully implement CSS3 media queries

http://lmgtfy.com/?q=css3+media+queries

http://mobile.smashingmagazine.com/2010/07/19/how-to-use-css3-media-queries-to-create-a-mobile-version-of-your-website/
0
 

Author Closing Comment

by:brucegust
ID: 38349669
Outstanding!
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses
Course of the Month17 days, 20 hours left to enroll

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question