PHP mobile browser detection?

后端 未结 10 1151
没有蜡笔的小新
没有蜡笔的小新 2020-11-30 06:03

I\'m in need of a way to detect mobile browsers server-side. I\'d like a way that requires me to do little to set up and little to maintain, yet still provide me with accura

10条回答
  •  不知归路
    2020-11-30 06:53

    Found this library a little while back:

    http://code.google.com/p/mobileesp/

    Has PHP, Java, JavaScript, and C# versions. I see it as a "lightweight" smartphone/tablet detection tool without dependencies and is regularly updated. I have mixed feelings about it though as some aspects of the code quality are a bit shaky.

    If you need something even lighter-weight, the WP Super Cache plugin for WordPress contains some long regex strings you could probably swipe.

    Browser sniffing based on user agent strings is always going to be flaky. I looked at WURFL and it is several MB compressed. Using that is overkill. A better approach is to detect the top devices in use on the website, design for those devices, and then call it a day.

提交回复
热议问题