WordPress.org

Ready to get started?Download WordPress

Plugin Directory

PHP Browser Detection

PHP Browser Detection is a WordPress plugin used to detect a user's browser. Please report any bugs on the support forums.

PHP Browser Detection is a WordPress plugin used to detect a user's browser. It can be used to send conditional CSS files for Internet Explorer, display different content or custom messages anywhere on the page, or to swap out Flash for an image for iPhones.

Using the Template Tags in your theme:

Test for specific browsers:

$version is optional. Include a major version number, a single integer - 3,4,5, etc... Or leave it empty to test for any version.

<?php if(is_firefox($version)) { /* do stuff */ }; ?>
<?php if(is_safari($version)) { /* do stuff */ }; ?>
<?php if(is_firefox($version)) { /* do stuff */ }; ?>
<?php if(is_chrome($version)) { /* do stuff */ }; ?>
<?php if(is_opera($version)) { /* do stuff */ }; ?>
<?php if(is_ie($version)) { /* do stuff */ }; ?>

Check for mobile, iPhone, iPad, iPod, etc...

<?php if(is_iphone($version)) { /* do stuff */ }; ?>
<?php if(is_ipad($version)) { /* do stuff */ }; ?>
<?php if(is_ipod($version)) { /* do stuff */ }; ?>
<?php if(is_mobile()) { /* do stuff */ }; ?>

Check for greater than / less than a specific version...

Less than or equal to Firefox 19:

<?php if(is_firefox() && get_browser_version() <= 19) { /* do stuff */ }; ?>

Less than or equal to IE 10:

<?php if(is_ie() && get_browser_version() <= 10) { /* do stuff */ }; ?>

Greater than or equal to Safari 4:

<?php if(is_safari() && get_browser_version() >= 4) { /* do stuff */ }; ?>

these are just a few examples, but this syntax will work for any browser or version.

Check specific versions...

Is the browser IE6?

<?php if(is_ie(6)) { /* do stuff */ }; ?>

Is the browser IE10?

<?php if(is_ie(10)) { /* do stuff */ }; ?>

Or you can get all the info and do what you want with it:

Get just the name...

<?php $browserName = get_browser_name(); ?>

Get the full version number - 3.2, 5.0, etc...

<?php $browserVersion = get_browser_version(); ?>

Or get it all in array...

<?php $browserInfo = php_browser_info(); ?>

Compatible up to: 3.8.3
Last Updated: 2014-1-24
Downloads: 18,943

Ratings

4 stars
4.7 out of 5 stars

Support

1 of 4 support threads in the last two months have been resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,2,2
100,1,1
100,1,1
100,1,1
100,1,1
100,1,1 100,1,1
100,1,1 50,2,1
100,3,3
50,2,1
33,6,2
100,1,1 100,1,1
100,2,2 100,2,2
100,1,1
100,1,1
100,1,1
0,1,0
100,1,1 100,1,1