I want to set $_SERVER['HTTP_USER_AGENT'] manually before calling get_browser() function.
<?php
...
$_SERVER['HTTP_USER_AGENT'] = $default_browser;
$browser = get_browser(null, true);
print_r($browser);
?>
but it gives me an error.
PHP Warning: get_browser(): HTTP_USER_AGENT variable is not set, cannot determine user agent name in /home/insu/a.php on line 6
Is it possible to set HTTP_USER_AGENT manually?
You can do this:
php $browser = get_browser($default_browser, true); print_r($browser);But you should not rely on
get_browser()since it's really slow.You can choose between a lot of Parsers here https://github.com/ThaDafinser/UserAgentParser