How to install user agent for get_headers PHP function

I know. It's easy to install a user agent for curling, but my code is based on get_headers, by default the user_headers agent is empty. Thanks for any help.

+4
source share
2 answers

Maybe this?

ini_set('user_agent', 'Mozilla/5.0'); 
+17
source

get_headers indicates only the data sent by the server to the client (in this case, PHP), it does not indicate request headers.

If you are trying to find the user agent with which the get_headers request was made, you will need to use:

 ini_get('user_agent'); 

For more documentation see the links below:

+1
source

Source: https://habr.com/ru/post/1384946/


All Articles