Does PHP provide a way to identify whether a user machine is a PC with a mouse and keyboard, or a touchscreen laptop?
Asked
Active
Viewed 389 times
0
-
what language? lol nobody can read minds here – washcloth Nov 11 '14 at 00:51
-
1"with PHP or other language" :) Let's go with PHP first given it's been tagged as such. – arkyc Nov 11 '14 at 00:53
-
this isn't too broad as he is only asking for a PHP method to detect either a mouse or touchscreen – Nov 11 '14 at 17:54
1 Answers
3
+1, Good question. Yes, identifying the user is important for better user experience.
Look into user agent detection. This might help you get started. They analyze the user agent (UA) string the browser sends when making requests. However, detection with PHP is probably limited, and Javascript will have to get involved to fullfill what you want.
There are various ways to detect whether a browser has a feature
- Detecting that the browser has no mouse and is touch-only
- Modernizr (used by Detector) this common Javascript library simplifies the task.
Look into conditional html/css/javascript:
- Conditional Formatting in HTML Tags
- Also, there are css vendor prefixes/extensions for Mozilla, Webkit, used by Chrome and Safari that only apply to a specific browser
Hope this helps you!

Community
- 1
- 1