Detecting the user’s browser type and version is helpful in web applications that harness some of the newer bleeding edge concepts. With the browser type and version you can notify users about challenges they may experience and suggest they upgrade before using such application. Not a great idea on a large scale public site; but on a private application this type of check can be helpful.
Please feel free to join us and you are always welcome to share your thoughts even if you have more reference links related to other tips and tricks that our readers may like. |
|
|
Learning a user’s browser and its version is usually very important to decide if any other scripts or styles need to be inserted into the web page.
And, such tasks are usually accomplished with JavaScript as we don’t need to go so deep (detecting if it is IE or not is generally enough).
Browser.php is a very useful PHP class that helps collecting data about a visitor’s browser including:
- platform used
- browser
- browser version
It can detect almost every popular browser including mobile + tablet devices and robots with a few lines just like:
1.
$browser =
new
Browser();
2.
if
( $browser->getBrowser() == Browser::BROWSER_FIREFOX && $browser->getVersion() >= 2 ) {
3.
echo
'You have FireFox version 2 or greater'
;
4.
}
If the need for browser detection is more than just analyzing whether it is IE, Firefox, Chrome or Safari, then Browser.php is definitely a must-bookmark.
Website: http://chrisschuld.com/projects/browser-php-detecting-a-users-browser-from-php/
Image Courtest of webresourcesdepot.com