php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #34683 get_browser ignores $_SERVER['HTTP_USER_AGENT'] setting
Submitted: 2005-09-30 07:52 UTC Modified: 2005-09-30 10:31 UTC
From: skissane at gmail dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: Irrelevant
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: skissane at gmail dot com
New email:
PHP Version: OS:

 

 [2005-09-30 07:52 UTC] skissane at gmail dot com
Description:
------------
According to the docs "By default, the value of $_SERVER['HTTP_USER_AGENT'] is used". However, setting this to a different value does not change the output of get_browser with no arguments. Indeed, under CLI SAPI, HTTP_USER_AGENT is not set initially, and even if you set it by hand before calling get_browser() it still gives an error that it is not set.

Reproduce code:
---------------
Run from CLI SAPI:
<?
$_SERVER["HTTP_USER_AGENT"] = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.7.10) Gecko/20050717 Firefox/1.0.6";
echo is_object(get_browser($_SERVER["HTTP_USER_AGENT"])) ? "Y" : "N";
echo is_object(get_browser()) ? "Y" : "N";


Expected result:
----------------
YY

Actual result:
--------------
Y
Warning: get_browser(): HTTP_USER_AGENT variable is not set, cannot determine user agent name in /data/www/simon/Handbook/test.php on line 4
N

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-09-30 10:19 UTC] sniper@php.net
It does use the HTTP_USER_AGENT. But it does not use it from $_SERVER['HTTP_USER_AGENT'], this is a documentation error.
(you can't just change any pre-set $_SERVER values!)

You need to pass the function the different browser agent string if you think the one found in $_SERVER['HTTP_USER_AGENT'] isn't correct.

 [2005-09-30 10:31 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

"By default, the value of HTTP User-Agent header is used."
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon Aug 04 16:00:03 2025 UTC