Code to parse user agent string?

戏子无情 提交于 2019-11-27 08:50:14
symcbean

The get_browser() function has been available in PHP for quite a long a time.

The PHP manual is free, can be downloaded in various formats and viewed online (with comments)

Martin Vseticka

https://github.com/browscap/browscap-php - this is a standalone library that aims to replace get_browser function. For shared hostings it seems to be a better option.

Works on: PHP 5

You can try to use: https://github.com/tobie/ua-parser. This is multi-language tool to parsing user agent string. For PHP is here: https://github.com/tobie/ua-parser/tree/master/php

Try out ThaDafinser/UserAgentParser it's an abstraction for many available user agent parsers.

So if you are not happy with one - just switch to another (or combine them)

You can try it out here

There is a PHP class library i found out, and it has worked so well for me. It is in the link below.

https://www.toms-world.org/blog/parseuseragentstring

It is lightweight and just does what I wanted (Browser, Version, OS, Mobile/PC, and much more) in a memory-friendy manner.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!