|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24548 get_browser() does not return platform
Submitted: 2003-07-08 16:20 UTC Modified: 2003-07-09 14:20 UTC
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: mikx at mikx dot de Assigned: jay (profile)
Status: Closed Package: Unknown/Other Function
PHP Version: 4.3.2 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: mikx at mikx dot de
New email:
PHP Version: OS:


 [2003-07-08 16:20 UTC] mikx at mikx dot de
The object returned from get_browser() function does not contain the platform information as described in the documentation and as usual in prior versions.

It's more a missing feature than a bug, but it brings some old scripts relying on this feature into trouble.

The browscap.ini is the latest "official" one from Gary Keith.

Reproduce code:
$browser = get_browser();
foreach ($browser as $name => $value) {
    print "<b>$name</b> $value <br />\n";


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-08 16:44 UTC] mikx at mikx dot de
Just figured out that get_browser() does not return a fixed set of informations - the platform information is only given if resolved.

It can't resolve most versions of Internet Explorer 6, not sure if this is a bug or a weakness of the browscap.ini.
 [2003-07-08 18:44 UTC] mikx at mikx dot de
Seems to be a bug in 4.3.2 - downgraded to 4.3.0 and get_browser() is able to detect the platform of much more HTTP_USER_AGENT strings now.
 [2003-07-09 06:12 UTC] alexandre dot alapetite at risoe dot dk
It seems that there is a problem with the get_browser() function.
It is not respecting the browscap.ini format.

For example (with IE6.0 Win2000) in the browscap.ini we can find
[IE 6.0]
which are the generic values for all IE6 browsers.
And is the this wrong one that is returned by get_browser() since the "IE 6.0" pattern is contained in the user agent string "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; Q312461)".

The good match in browscap.ini for IE6 Win2000 should be
[Mozilla/4\.0 (compatible; MSIE 6\.0.*;.*Windows NT 5\.0.*).*]

The solution for IE6 is to replace in browscap.ini
[IE 6.0] by [Internet Explorer 6.0]
and parent=IE 6.0 by parent=Internet Explorer 6.0

This way it will return also the platform, the browser, etc...

But PHP should update the way they analyse regular expressions from browscap.ini which are in fact of the form
[^xxx$]. That meens that expressions in browscap.ini are always full pattern and not just a peace.

Hope it will be corrected soon.
 [2003-07-09 07:33 UTC]
Jay, can you look into this?

 [2003-07-09 13:53 UTC]
Please try using this CVS snapshot:
For Windows:

This has been fixed in CVS for PHP 5 and I've merged the 
changes over. Try the next snapshot and see if it provides 
better matches. It reports Win2000 now for your example, 
others should work as well.  
 [2003-07-09 14:17 UTC]
Please try using this CVS snapshot:
For Windows:

Jay meant this snapshot, of course. :)

 [2003-07-09 14:20 UTC]
Ah..he already committed the fix to the stable branch too.
Case closed.

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jul 20 12:01:28 2024 UTC