Our PHP browser detection scripts are all tested on every browser we have access to: Opera, Mozilla (and other Gecko engine browsers), Firefox/Iceweasel, Netscape, to MSIE, Galeon, K-Meleon, Lynx, Safari/Chrome (and other WebKit engine browsers), KHTML / Konqueror, and Mac IE browsers like IE 5.1 and 5.2. The full version also detects most spiders, and an assortment of uncommon browsers and other user agents. They are being used in one form or another on our sites.

If you don’t need the complex browser detection script, you can get two simpler versions here.

Current features: Mozilla, IE, Safari (and other AppleWebKit browsers, Chrome, Epiphany), Konqueror, and Opera browser version detection on our full featured PHP browser/os detection script, as well as Windows OS version detection, basic Mac OSX detector, Linux/Unix detection, including release/distro name. Mobile detection just added.

Script Download

Download: complex, full featured PHP Browser Detection

Current Version: 5.2.0

File Last Modified: February 02, 2010. 15:32:09 pm

Your Computer Box

We’ve been asked how to implement the “Your Computer Information” box on this page, so we put it in a script.

Download: ‘Your Computer’ Box Script

Current Version: 1.2.0

File Last Modified: February 02, 2010. 14:45:05 pm

This script is a simplified version of the one to your left, for easy use.

PHP Language Detection

NEW! – PHP system language detection script. Check it out if that’s something you need for your site.

Your Computer

Operating System:


NT 5.2 (Windows XP x64 Edition or Windows Server 2003)

Current Browser / UA:

Mozilla/ Firefox 3.0.15

ProductSub: 2009101601

Engine: Gecko RV:

XHTML support: Yes

System Language

Primary Language id: en-us

Primary Language:

English (United States)

Current Screen Resolution

1280 x 720 pixels


JavaScript is enabled.


Cookies are enabled

Version 5.2.0 New return value: true_msie_version

This data is also returned in a new full return array item, index 14 ($true_msie_version). Since MSIE 8.0 is using a compatability mode which changes the user agent string to say it’s MSIE 7, this will detect that change and offer the true version. Only for MSIE 8 masquerading as MSIE 7.

This is also now integrated into the latest Your Computer Box script version, as you can see if you turn MSIE 8 compatibility mode on. The box to your left should then show both the real version and the compatibility mode version.

Also a major cleanup of comments, clarification of top comment descriptions of return data to make it a lot more readable for new (and old) users.

Version 5.1.0 With New Arguments: Optimization Parameters

New optional argument, second primary function parameter with possible values: 1 2 3

1 turns off os detection functions, 2 turns off mobile detection functions, and 3 turns off both. Leaving argument 2 blank leaves it default. This can help cut script execution times down quite a bit if you don’t need os and / or mobile data.

Version 5.0.4 With Mobile Detection Released! Read Changes Below

I expect fine tuning and adding more handheld/mobile data to this over time, but I think this should get probably more than 95% of current devices reasonably well. We’ll see how it goes.

Please note that if you use the your computer script, you need to update it to the current version, there will be a failure on mozilla and webkit output unless you change those lines, or update the script.

Many thanks to for their invaluable list of UA strings for handheld and other weird devices.

Updated mobile_data array values :: v. 5.0.4

To avoid breaking this in the future, I redid the return values, and added one new type:

$mobile_device, $mobile_browser, $mobile_browser_number, $mobile_os, $mobile_os_number, $mobile_server, $mobile_server_number

This will break earlier version of your computer info box script if you use that. However, this change was worth making because it is now more consistent and I can add another identification category in the future without breaking the order of the array items. The only future change will be in adding possible either methods for id’ing mobile devices. $mobile_server is somethign like CTS, Novarra-Vision for example, or DoCoMo.

Also a bug fix in this one, and added some more id methods. I expect this to change over time as user feedback exposes errors and failures, but from now on the actual array order should not change, although the items themselves might get shuffled around to be more accurate.

New Return Values

To handle mobile detections: new parameters: ‘mobile_test’ and ‘mobile_data’. Test returns a string or null if it’s a detected mobile type. Data returs an array of mobile data or null if it’s not a mobile type.

To handle the new Webkit parameter, new option: ‘webkit_version’ added. Also added ‘moz_version’ and ‘webkit_version’ return arrays to full return array so you don’t have to call browser detection twice in case of Mozilla or Webkit browsers.

This should not change any existing code for you, they are just new extra items. But if you want to check your code to see if this can slightly optimize your pages, then that might be worth it if you use either Mozilla or Webkit in the page handling code.

Mobile Detection

By popular demand. Please note that there are a few changes now. ‘full’ now returns ‘mobile_test’ and ‘mobile_data’ as the last array items. Os type has: ‘android’, ‘blackberry’, ‘iphone’, ‘palmos’, ‘palmsource’, ‘symbian’ added to basic tests. Windows is still going to return the ce as version number for windows ce, but you should consider that deprecated and test for ‘windows ce’ in the mobile_test string instead if you need that.

‘mobile_test’ always runs, and returns either in ‘full’ array data, or as its own test. This will just be a string of however the script found the mobile. There will probably be bugs with this. ‘mobile_data’ is an array with these items: $mobile_device, $mobile_browser, $mobile_browser_number, $mobile_os, $mobile_os_number, $mobile_server, $mobile_server_number. Please note that the numbers are going to be best guesses only, and will encure some script overhead to get, since they involved resending data through functions.

The ‘type’ parameter also now returns ‘mobile’ as well as ‘bro’, ‘bbro’, and ‘bot’ to make testing easier for hand held/mobile devices.

iPhone/hand held OS Detection

iPhone should not have been in the browser detection, that was a mistake, it is now in the os detection, with the other primary handheld os systems: ‘android’, ‘blackberry’, ‘iphone’, ‘palmos’, ‘palmsource’, ‘symbian’.

For more precise handheld device detection use the basic ‘mobile_test’ and the full test array ‘mobile_data’ options instead. The ‘type’ parameter now also has ‘mobile’ as a return value for easy testing.

WebKit Detection

WebKit handling: now detects and returns as browser type array: Safari, Epiphany (webkit build), Google Chrome, Omniweb (and more), with Webkit type version number (ie, Chrome 1.2), and the Webkit number (ie Webkit/442).

Please note that this adds a new return parameter, webkit_version, which returns an array of the webkit data (specific browser name and version number, plus webkit version number). The iPhone detection was removed from this and put into OS and Mobile parameters where it belonged.

Pre Version 5.0.0 Updates and Changes

Unix / Linux Version Detection

Linux version detection. Since most Linux browsers don’t have much about the Linux version in the useragent string, this is pretty basic, but added anyway.

Netscape 2,3,4 detection

The script has been changed to actually id the old netscape browsers correctly, for those who who really want the most accurate. This can be useful for old Unix / Mac computers that still run these original Netscape browsers and can’t update.

Important: If you are updating your script and were using the old ‘ns4’ to test for Netscape 4 you will have to modify your page code to test for ‘ns’ and for ‘number’ just like you do with Opera and Internet Explorer.

About the Browser Detection Scripts

All our php browser detection scripts have been thoroughly tested, although of course no script is ever perfect, so they will be modified as time goes by. There is a ‘last modified by’ date scripted in next to each download so you can see if it has changed from the version you have. Please post any problems with the detection script in our web programming forum. If you do find something wrong with a script, we’ll get it fixed and post an updated version as soon as we can get to it.

The full featured PHP browser detection script also include a decent OS detection, that is currently being expanded. It currently identify most Windows, Mac OS X, some Linux, some Unix, more will be added as time permits. Also allows you to test for all the major search engine spiders, site downloaders, and http libraries.

Please Link to our Site

It would really help us out, and help other people find this information, if you could add a link to our site in exchange for these scripts. Thanks.

<a href=””> PHP Browser Detection</a>


Full Featured Browser Detection PHP Script

Configuration information

This script features a way to extract the browser name and version number from almost any navigator user agent that might be visiting, but in many cases that’s not desirable, for example if you want to deliver some CSS or code to a default ‘unknown’ type browser. In that case you would want the script to return the value ”, browser == ” that is.

To make the script return a default value of ” for unrecognized user agents, search the page for this string:

// delete this part if you want an unknown browser returned

then follow the directions, delete first part, uncomment second part.

Download the text file of the browser detection script and run either as an include or insert directly into your PHP code. This is the more complex version of our PHP browser detection script. Due to the size of the script, we recommend optimizing the use of the browser detector. You can find one way to optimize the running of the script here in our tech forums.

This script uses arrays to hold both browser and OS versions. It checks these against the navigatorUserAgent() strings, then packs either os or browser variables with the proper browser and os information. It also features several different test return conditions which should cover most situations you run across.

The main advantages of this browser detection script is that it will not be fooled by Opera or Safari, no matter how Opera is set to identify itself. It can also be used to deliver browser specific CSS stylesheets to the page depending on what browser is requesting the page. Since this is run on the server side, it doesn’t require client side Javascripting to be enabled to function.

This code is more or less what we use for all our websites, in one form or another, when we need to set browser CSS and other coding particulars.

Currently this script identifies the following specific browsers: Opera, Internet Explorer 4, Internet Explorer, Mozilla/Netscape Gecko based browsers, Netscape 4.x, Konqueror, Safari. It id’s Linux, Mac, most of the main Unix flavors, Windows NT, Windows regular. It is easy to add more browsers and OS’s if required.

This small sample script gives some examples of how the detector can be used, in the first case it will print out the browser number, the browser, the operating system, and the operating system number or version (in the case of Unix) if available. The second example shows how you could use it in any of your scripts where knowing what browser is helpful.


echo ( browser_detection( 'number' ) .'<br>'.

browser_detection( 'browser' ) .'<br>'.

browser_detection( 'os' ) .'<br>'.

browser_detection( 'os_number' ) );


Outputs (browser version, browser, os, os number):






if ( ( browser_detection( 'browser' ) == 'ie' )


( browser_detection( 'number' ) >= 5 ) )


echo 'it is Internet Explorer ' .

browser_detection( 'number' );

// or anything else you want to happen of course




This is your browser useragent string:

Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv: Gecko/2009101601 Firefox/3.0.15 (.NET CLR 3.5.30729)

Manual Downloads

If for some reason the above download links didn’t work, you can download these scripts here:

Leave a Reply

Your email address will not be published. Required fields are marked *