ewebbrowser Detect user’s browser type and version

  1. Usage
  2. Resources

This is a ported Yii version of the great Browser class made by Chris SChuld.

There are already some extensions for this class here, but they are wrappers and this is a full Yii CComponent class. I wanted to use it Yii style and also even provide an event on browser discovery.

I have created a GitHub repository for those willing to contribute on any of the extensions I created. Please, check the link at the bottom of this wiki.

Usage

How to use this extension is quite simple, check the code below:

$b = new EWebBrowser();

echo '__toString<br>';
echo $b;

echo '<p></p>';
echo '<h3>Testing properties now</h3>';
echo 'user agent: '.$b->userAgent.'<br>';
echo 'platform: '.$b->platform.'<br>';
echo 'version: '.$b->version .'<br>';
echo 'browser: '.$b->browser.'<br>';
echo 'is Chrome? '.($b->browser == EWebBrowser::BROWSER_CHROME?'YES':'NO');

If you wish to rather use an event approach, do the following (assuming you have a class with static method 'discover'):

// the class handling the browser discovery
class ETest {
	//put your code here
	public static function discover($event)
	{
                // check all properties of EWebBrowserEvent
                echo $event->browser_name. '<br/>';
                echo $event->agent. '<br/>';
                echo $event->version . '<br/>';
                echo $event->platform . '<br/>';
                echo $event->os . '<br/>';
	}
}

// now on creation it will call the static method above
$b = new EWebBrowser(null, array('ETest','discover'));

Resources

6 0
13 followers
812 downloads
Yii Version: 1.1
License: BSD-2-Clause
Category: Others
Developed by: Antonio Ramirez
Created on: Oct 14, 2011
Last updated: 12 years ago

Downloads

show all

Related Extensions