php - How to determine whether the access comes from PC or mobile?
过去多啦不再A梦2017-05-27 17:42:54
0
5
694
Mainly the judgment comes from the PC side, because some operations must be performed on the computer. It comes from the mobile side, hiding some functions.
Of course, if you still need to judge Android or iOS, there is a simple method. Customize the value of HTTP_USER_AGENT on the mobile side, and then get $_SERVER['HTTP_USER_AGENT'] from the server. For example, add a my_webapp to determine whether this character is Existence
The assistant class is as follows:
The principle is to verify the header
Mobile_Detect
是轻量级php
库通过User-agent
和特定的人Http
Judge by the head:Mobile_Detect
Post the code in THINKcmf
Of course, if you still need to judge Android or iOS, there is a simple method. Customize the value of HTTP_USER_AGENT on the mobile side, and then get $_SERVER['HTTP_USER_AGENT'] from the server. For example, add a my_webapp to determine whether this character is Existence
I answered this question in segment fault, and the questioner said it was valid at that time: /q/101...