Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
For 2023 - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Which browser is being used?

Posted by enquirer (enquirer), 31 December 2002
How do I tell which browser my web site visitor is using so that I can tailor my HTML to suit?

Posted by admin (Graham Ellis), 31 December 2002
PHP has a built in get_browser function but it isn't just as simple as calling that function.  A browser capability file called browscap.ini is required, and reference has to be made to that file in your php.ini file.  The browser capability file is NOT supplied with the main PHP distribution; that's said to be because of copyright reasons, but personally I suspect it's because browsers change so much that it's simply out of date too fast and the PHP folks don't want to get blamed fopr any errors.

If you want to use browscap, you might like to try the following locations for the file:
which however are all incomplete or out of date to some extent.

As an alternative, you may wish to return to "first principles" and write your own simple function based on the $HTTP_USER_AGENT variable, from which you can quickly work out if you have a copy
of Internet Explorer (look for the string MSIE), Netscape, or some other browser, and the version number.

Here's a sample web page (on a system onto which we have installed a browscap file) which shows both information sources in use.

<title>Browser Version Reporter</title>
<body bgcolor=white>
<h1>About Your Browser</h1>
<table border=1>
print "<tr><td colspan=2>$HTTP_USER_AGENT</td></tr>";
$browser = get_browser();
   while (list ($key, $value) = each ($browser)) {
   $str .= "<tr><td>$key</td><td>$value&nbsp;</td></tr>";
print $str;

And here are the results of calling up the page from an Internet Explorer browser running on Mac OS X 10.1

Mozilla/4.0 (compatible; MSIE 5.14; Mac_PowerPC)
browser_name_pattern      Mozilla/4\.0 (compatible; MSIE 5\..*) 
parent      IE 5.0 
browser      IE 
version      5.0 
majorver      #5 
minorver      #0 
frames      1 
tables      1 
cookies      1 
backgroundsounds      1 
vbscript      1 
javascript      1 
javaapplets      1 
activexcontrols      1 
cdf      1 

Posted by John_Moylan (jfp), 2 January 2003
...and there just happens to be a recipe in the pdf of the sample chapter of the PHP cookbook.

It does look good, I should just get it instead of waiting for reviews, after all, it is an O'Reilly book
Which leads nicely onto my next post.  


This page is a thread posted to the opentalk forum at and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2023: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: • WEB: • SKYPE: wellho