Detecting Browser and Browser Capabilities with PHP


Detecting browsers and collecting data about browser capabilites can be done with Javascript or Activex, but there is still a long way away from being 100% accurate.

There are thounsands of browser types to detect. In every update of IE/Firefox or etc. the specific version of the browsers are changing.

Now, there are over 120.000 known browser UserAgents.

So, It’s hard to collect all of the data about browsers, and testing-detecting.

What is Browscap

Gary Keith says in ;

Microsoft had a good idea when they created browscap.dll and browscap.ini to use with their web server for browser identification.

In theory, someone at Microsoft would routinely update the browscap.ini file and make it available to its customers. As a result we would all have reliable browser identification in order to know exactly what features the client’s browser supports.

Sadly, Microsoft never made any attempt to keep the file up to date.

There was a brief wellspring of volunteers who did a good job of maintaining browscap.ini for a while. Those sources are now either intentionally out of date as a way to drive product sales, or no longer exist. I can’t blame them for giving up as this is not an easy project to maintain.

Here is what I do as part of my project.

Shortly after midnight on Sunday morning the website log files for this site and over thirty other sites of various types are downloaded for analysis. Once downloaded the log files are analyzed on a number of levels. Over the years I have developed a number of systems for automatically collecting the data I need for further analysis. The vast majority of new user agents each week are variations on existing user agents in my database, so when the analysis is complete I usually wind up with around two dozen truly new and unique user agents to investigate. I typically do my research on Sunday afternoon and only a few new user agents from major search engines and popular browsers are eventually added to the files in any given week.

User agent detection is still a long ways away from being 100% accurate though because there will always be new user agents that aren’t in the files yet and hence won’t be properly identified. There are also the bugs in both browscap.dll and PHP’s get_browser(), which my files also support, to contend with. And of course there are always spoofed user agents. User agents that claim to be one thing, but in fact are often badly behaved bots masquerading as well behaved bots like Googlebot.

Approximately once a week the raw data in my database is compiled into various reports, including the all-important browscap.ini file for browser identification, and gets uploaded to this website.


browscap.ini is compatible with IIS 5 and later,

browscap.ini is compatible with PHP 5 and later,

browscap.ini is compatible with Sun One Asp on Windows.


Frequently Asked Questions

Configuration (Optional)

When you checked your php.ini file on your php folder or serve, search for “browscap”, you will find this :

; browscap = extra/browscap.ini

You can configure the settings, and the location for browscap file.

As I said in the tittle, this is optional.

Browscap Parser

You can use one of this parsers :

Setting Up

Put Browscap.php (the parser) and php_browscap.ini in the same folder. Next create a new file called test.php in the same directory and put this inside it:

Next create a sub-folder called cache, Browscap.php will store information for quick access here. Now if you visit test.php in your browser (assuming it is on your server) you should see your browser info displayed to the screen!

To access individual tidbits of information simply access $data as an object:


Update your browscap.ini file  very often, I offer you to check the updates weekly, or twice in a week.

Javascript inside PDF – Detect Browser Acrobat Reader Version


Yesterday I had a chance to met with “Adobe Acrobat X Pro“. I feel remorse for meeting lately to such a wonderfull software, Acrobat X.

If you need a complete PDF editor, just check out.

How Can a Pdf Editor be so Bully?

With “Adobe Acrobat X Pro”, you can :

  1. Save PDF files as Word documents with improved preservation of formatting and layouts. Relative positioning of tables, images, and even multicolumn text is preserved, as well as page, paragraph, and font attributes.
  2. Combine a wide range of file types into a polished, organized PDF Portfolio. Apply professionally designed layouts, visual themes, and color palettes. Easily add corporate logos and colors to reflect your branding.
  3. Quickly bring ideas to life through rich, interactive documents. Insert audio, Flash Player compatible video, and interactive media into PDF files, for seamless playback in Adobe Reader X or Reader 9.
  4. Automate routine, multistep tasks into a guided Action. Create, manage, execute, and share a sequence of frequently used steps that can be applied to a single PDF or batches of files.
  5. Eliminate confusion and improve version control. Easily identify differences between two versions of a PDF file by having Acrobat analyze both files and highlight changes to text and images.
  6. Enable Adobe Reader X or Reader 9 users to participate in shared reviews, fill and save forms, and digitally sign and approve PDF documents — regardless of platform or operating system.
  7. Easily convert existing forms to fillable PDF forms with intelligent form field recognition, or design them yourself using included templates. Collect data quickly and export to spreadsheets for analysis. Track and manage responses.
and more..
I will focus on the 3. – 4. and 7th items, that I marked as bold. Living and interactive documents? Inserting audio, Flash player and more interactive media.. I’m looking like this now => :O
Pdf documents are always one of the key points that is always discussed in securty forums. With Html5, we have the ability to include pdf’s to our webpages without Javascript&Activex. This new features in Html5 shows us the future of pdf documents.

You are not still excited? Then check this showcases :

– Amy Graff, Professional Student and Instructor

If you have Adobe Reader or Adobe Acrobat installed on your system and your browser supports Html5, you should see the embed pdf document, that show your Reader or Acrobat version with Javascript.

Lets take a deeper look inside this Pdf file.

This PDF created as a Form Application, and checking the Adobe Reader version and Adobe Acrobat version with ACRO_script – JavaScript.

You can see the forms in the PDF file, like a simple Html page or a server-side-languages.

I said server-side-languages because the form applications those collects a value or stores the form input in a database, these are the attirubutes of Pdf files with Acrobat.

Detect Client Browser’s Reader or Acrobat Version

Now take a look to Javascript too :

The whole code :

You can develop my example with your own Javascript knowledge.

Finally I can easily say, Javascript will never die! Jquery, Mootools, Ajax and more..

Mustafa Serhat Dündar

Installing Eclipse on Ubuntu 10.04 and Configuring PyDev

What is Eclipse?

Eclipse is an open source community whose projects are focused on building an extensible development platform, runtimes and application frameworks for building, deploying and managing software across the entire software lifecycle. Many people know eclipse as a Java IDE but Eclipse is much more than a Java IDE.

Check this for more :

What More than a Java IDE?

Eclipse is a IDE for;

Java , JavaEE, C, C++, C#, PHP, Javascript, Mobile Development, RCP & RAP, UML, Error handling, Maven, Python, Ruby..

Check Download Place ;


Marketplace (for plugins, bundles etc.) ;

Installing Eclipse on Ubuntu 10.04 Lts

I’m gonna talk about the easiest way to install eclipse on ubuntu, you can find other ways like terminal installitions or more like that.

You can use the Ubuntu Software Manager as the easiest way.

(Applications => Ubuntu Software Manager)

Type “eclipse” to the search box, that is placed at the right corner.

Select “eclipse” and “Install” it.

I know, there is no “install” option at the screen, because I installed eclipse before.

The install process may take some time according as your internet connection speed and system configuration.

When the process is done, you can reach eclipse under “Applications >> Programming >> Eclipse“.

Installing and Configuring the PyDev Plugin

1) Launch “eclipse”. When the workbench loaded, you will see the “Workspace Launcher” window. If not, don’t care, You can open it from “File -> Switch Workspace -> Other”.

You can change the path for workspace always, I have a folder on my desktop, named as “python” so I choose that path. If you want to change the path after, you now the way “File -> Switch Workspace -> Other”.

Now, you should see the welcome screen of Eclipse IDE.

Click on the arrow on the right to go to the workbench.

Go to “Help -> Install New Software

Select “Add“.

Enter “” under Location and click OK.

Back in the “Available Software” window, select the “PyDev for Eclipse” option. Do not select the “PyDev Mylyn Integration“.

Click “Next“, verify that PyDev is selected in the next window then select “Next” again.

Select “I accept the terms of the license agreement” then select “Finish“. The installer will begin to download the plug-in. A window may appear asking you whether you want to install the plug-in. Select Install All.

A security warning may appear asking whether you trust the software being installed click “ok” then ensure the correct items are selected and click yes and the instillation process will continue.

When the installation is complete, you will be asked if you want to restart Eclipse. Select Yes.

Now.. PyDev is installed succesfully on your Eclipse IDE.

It’s time to configure that plug-in !

Go to “Window> Preferences”. In the Preferences window, expand “Pydev” and select “Interpreter-Python“. Click “New”

Type your interpreter name, python31 maybe..

Select the Interpreter executable, usually and defaultly usr/bin/python3.1, If you installed in a different location type it.

And click “OK“. “Selection Needed” Window will appear. Leave it with defaults, if you don’t know what are you doing.

That’s it, welldone you configurated your Eclipse for Python.

Now lets see, what can we do in Python !

Go to “Window > Open Perspective > Other” and choose “Pydev“, then click OK. If you look at the upper right corner you will see that the perspective has changed from “Java” to “Pydev“. If it is not neccessary for you, right click on “Java” and select “close“.

Select “File -> New -> Project”. Select “Pydev -> Pydev Project”.

Choose “python” as the “project type”, and “3.0” as “grammer version” and “python31” as “interpreter”.

Make sure “create default ‘src’ folder and add it to the pythonpath?” is selected. Click “Finish”.

Select the project you just created and go to “File → New → Pydev Module”. This will launch a new Pydev Module Wizard where you should enter a name for your module and make sure it is in the right location. Leave the Package field blank and select “Finish”.

Now you sould see the file in ypur project. Open it if eclipse open it automaticly. Type some code, and run it.

Now you can see the print result at the “console” window.

A tweak for Eclipse :

We can understand the errors with highlight function of eclipse, but the line numbers can be pretty usefull for us too.

To show line numbers, right click on the bar that you can see in the next screen, and select “Show Line Numbers”.

Well done lads, see you soon.

/ M.Serhat Dundar /