I need to know the exact name of the browser without a version using php , thanks. To output, for example: MSIE or Opera or Chrome, etc. etc.
- The task has no solution when using only php. - Visman
|
1 answer
Through superglobal array.
$_SERVER['HTTP_USER_AGENT'] Via get_browser .
Or, as noted below, through third-party solutions - ua-parser .
- In addition to the actual name of the browser, the user-agent also contains a bunch of garbage. To isolate the real name from there is a separate complex task. - Dmitriy Simushev
- Just parse as a string. Check for certain substrings. - qtm
- It only seems that way to you. In fact, the parsing rules are some nontrivial. For example, almost every user-agent contains a
Mozillaline (even those that have no relation to this company at all). Another MSIE line is often encountered, but this does not mean that the browser = IE. Curious example . - Dmitriy Simushev - Then through
get_browser. This option is more convenient, but I would not say that it is easier. - qtm - In fact, you just need to use a special tool for parsing user-agent =)) For example, ua-parser . - Dmitriy Simushev
|