J
J
JackShcherbakov2018-01-29 21:08:51
PHP
JackShcherbakov, 2018-01-29 21:08:51

How does HTTP_USER_AGENT work and what is the use of it?

Hello! From the php book, I realized that HTTP_USER_AGENT is needed in order to find out the user's browser. But for some reason, when I go to the site from Yandex or any other browser, I get this

HTTP_USER_AGENT - Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 YaBrowser/17.11.1.988 Yowser/2.5 Safari/537.36

So what's the point of this line? How can I find out which browser is being used? Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
DanKud, 2018-01-29
@JackShcherbakov

The variable, as you understand, is needed to determine the user's browser and operating system. For what purposes to process this data in the future, everyone already decides for himself. Primarily used to identify a mobile or desktop device, of course, in order to display the appropriate page for the mobile or main version of the site. Also in different browsers there are some nuances of page display that can be fixed if you determine the user's browser. With some knowledge, you can process the string yourself and display the values, but there are a lot of user libraries that will process it for you without any problems and show the necessary information.
For example https://github.com/ornicar/php-user-agent or https://github.com/zsxsoft/php-useragent

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question