Chris Schuld's Blog

personal musings on the composition of software

Written By: Chris Schuld Saturday, November 8th, 2008

I updated the Browser.php class today to detect Google’s Chrome Browser. Additionally, thanks to an idea from Daniel ‘mavrick’ Lang, I added isBrowser($browserName) as a function to version 1.1.

Visit the Browser.php class page today to grab the update!

Interested in a PHP4 version? Daniel is maintaining a version for PHP4.

Example Usage:

1
2
3
4
5
6
7
8
9
10
11
12
 
 
$browser = new Browser();
if( ! ( $browser->getBrowser() == Browser::BROWSER_FIREFOX && $browser->getVersion() >= 2 ) ) {
	echo 'You have FireFox version 2 or greater';
}
 
// AND NOW...
 
if( $browser->isBrowser(Browser::BROWSER_CHROME) ) {
	echo '<p><strong>Hi Google Chrome User!</strong></p>';
}
Categories: PHP, Web Development

Leave a Reply

About Chris

Chris Schuld

Thank you for visiting my website. I use this site for a myriad of things: maintaining software I have open sourced, connecting with my readers and friends and documenting all of this little things "I wished I would have written down." You can read more about me or contact me.


thanks for visiting... happy coding

Recent Comments