02 May 2010

PHP: Quick & handy browser sniffer/checker function/class

Yes, you can check your visitor's browser using PHP! What's more, it never goes out of date! It automatically updates to recognise the lastest browsers. As much as I'd like to, I can't take credit for this one - it's the work of Jonathan Stoppani and makes browser sniffing with PHP an absolute breeze.

This class (named Browscap) is a great alternative to PHP's native get_broswer function which requires manual regular updating of a browser.ini definitions file. Instead, Browscap intermittently imports the latest browser definitions from browserproject.com  so that your scripts are always up to speed with the latest browser information.
Instructions and download below...

I've made a few edits to Jonathan's great class to make it a bit easier to implement. All you need to do is download the files below and add these two lines to your PHP script:


require("path/to/checkbroswer.php");
$browserInfo=checkbrowser(); //returns array of info on the browser (print_r($browserInfo) to view)

//alternatively, if you dont need all that array data:
$browser=checkbrowser('Browser'); //returns Case sensitive browser name (Firefox,Chrome,IE,etc)
$version=checkbrowser('Version'); //returns browser's version number (3.6, etc)

For details on what is returned in the array check out the Browscap website

» Download the modified Browscap file

NOTE: This is quite slow for one visitor every 10 days (which I can live with!) as it has to import the definitions file. Otherwise all data is cached and it should be nice and fast.

23 comments:

Unknown said...

canada goose
coach factory outlet
coach outlet
ray ban sunglasses
fit flops
canada goose jackets
kate spade outlet
cheap oakleys
birkenstock sandals
birkenstocks
20161228caiyan]
\

Unknown said...

ugg canada
discount oakley sunglasses
moncler outlet
coach outlet online
canada goose
canada goose outlet
cheap ray ban sunglasses
longchamp outlet
salvatore ferragamo shoes
coach outlet
adidas shoes

chenlili said...

nike air force 1
hermes outlet
michael kors outlet
coach handbags
prada
ray ban sunglasses
louboutin
adidas outlet
y3 shoes
rolex watches
20186.6chenjinyan

Unknown said...

20180623xiaoke
christian louboutin
oakley sunglasses wholesale
kd 10 elite
ray ban sunglasses outlet
pandora charms
true religion jeans sale
ralph lauren outlet
canada goose jackets
ugg boots on sale
chloe sunglassess

Unknown said...

timberland boots
montblanc
converse shoes
nike mercurial
longchamp outlet
fendi
converse
coach outlet
lebron 11
longchamp bags
2018.6.28LINYING

chenlili said...

nike free
kate spade outlet
oakley sunglasses
oakley sunglasses
arc'teryx clothing
moncler outlet
adidas outlet
ugg clearance
longchamp
coach outlet
chenyingying20180908

Unknown said...

michael kors outlet
rolex
mont blanc
armani handbags
goyard handbags
oakley sunglasses
lacoste jeans
ugg outlet
oakley sunglasses
nike store
2018.10.16chenlixiang

MANI said...

I am sure you see the trend here... Commercial Mortgage Financing can be used in practically any industry for any kind of commercial property. Speak with your Business Finance Broker when you are ready to invest in a Commercial Real estate opportunity. www.financetypes.us

MANI said...

Make use of a travel agent that provides travel deals for handicapped travelers. Booking plane tickets and rooms in hotels with journey agents that provide travel methods to disabled individuals is advantageous in many ways. They make sure they book for his or her disabled customers airlines as well as hotels which are disabled pleasant. They make an effort to offer providers and suggestions which will ensure their own clients journey comfortably. www.bestadventuretravel.us

MANI said...

One of the biggest competitions of today is staying fit. It seems like people nowadays want to lose weight instantly as if there is no tomorrow or it is as if it is a passport for the general population. Losing weight and staying fit is never easy. www.bestadventuretravel.us

MANI said...

The laws of nature are just as they treat every specie (and not only man) with equality. In a jungle, every specie gets its due share of food, air and water which enable them to live a dignified life without being dependent on any other creation. Nature makes no distinction between one specie, and the other as all species are the children of the same God. www.lawinformation.us

MANI said...

I am certain you begin to see the trend right here... Commercial Home loan Financing may be used in virtually any business for any type of commercial home. Speak together with your Business Finance Broker when you're ready to purchase a Commercial Property opportunity. www.mybusinessplan.us

MANI said...

You will see all styles and models of fashion blogs as being the internet is stuffed with them. It can take a look at the advantages of wearing lean jeans through boyfriend bluejeans or the best way pink takes the destination of dark colored plus many of the extras. Just like you go internet, you receives your fill of your latest popular trends as a result of fashion blogs. www.stylesbeautytips.com

MANI said...

Real estate shareholders live in addition to die by means of their chance to add importance. With not any added importance, there usually are no gains. This applies with almost any business, but what makes real estate a really great business as well as a great investment decision, is the volume of ways you can contribute value and benefit from big gains. www.realestatevalley.us

MANI said...

Health fitness tips also recommend that vices should be stopped. Smoking predisposes one to vascular conditions such as arteriosclerosis and heart diseases. Alcohol consumption need not be eliminated but should be limited to 30 jiggers a day only. Alcohol still has health benefits such as vasodilation. These are just some of what Health fitness tips recommend www.healthyactivities.us

MANI said...

Insurance can be synonymous to a lot people expressing risks involving losses expected coming from a supposed car accident. Here, the price of your losses are going to be borne by the many insurers. www.insuranceguider.us

MANI said...

Discomfort heard this argument intended for spending far more now with quality just to save money in the future. But why not consider the impression your purchase has on the earth, shouldn't shopping ethically participate in the talk too? www.servicesexpert.us

MANI said...

Health fitness ideas also suggest that vices ought to be stopped. Smoking predisposes someone to vascular conditions for example arteriosclerosis as well as heart illnesses. Alcohol consumption do not need to be removed but ought to be limited in order to 30 jiggers each day only. Alcohol nevertheless has many benefits such because vasodilation. These are are just some of what Health fitness ideas recommend www.healthimprove.us

MANI said...

Traveling, for individuals with disabilities, is extremely hectic, particularly when they get to the airport terminal. They face the process of obtaining proper info and instructions. This is actually further aggravated through the huge number of individuals traveling as well as long lists. In international airports, there tend to be attendants which are supposed for carrying on the needs of these travelling along with disabilities. www.safetravelguide.us

MANI said...

I know you start to see the trend the following... Commercial Mortgage loan Financing can be utilized in almost any market for almost any commercial house. Speak along with your Business Finance Broker if you are ready to buy a Commercial Real-estate opportunity. www.financialgrow.us

MANI said...

You will find all forms and shapes of fashion blogs as the internet is full of them. It can talk about the main benefit of wearing lanky jeans over boyfriend jeans or how pink takes the place of black plus all the extras. As you go online, you will get your fill of the latest in fashion trends via fashion blogs. www.newsvillage.us

MANI said...

Most of us have heard the actual argument with regard to spending much more now upon quality in order to save money later on. But how about the effect your purchase is wearing the globe, shouldn't shopping ethically participate the dialogue too? www.newsvillage.us

MANI said...

You can find all kinds and forms of fashion blogs because internet is brimming with them. It can mention the luxury of wearing lanky jeans around boyfriend skinny jeans or precisely how pink takes the best place of dark-colored plus the many extras. Because you go on-line, you is certain to get your fill in the latest popular trends through fashion blogs. www.onlinefashionshop.us

Post a Comment

Cron Design Studio: Dublin based web design & software development