Skip to main content

Browser Class by Bluesman

A friend of mine and colleague Goran Pilipović (also known as Bluesman in developers community) recently sent me his own version of mine Browser Detection class.

Practically speaking, it is completely new code, because compared to my rather simple class this one has bigger number of methods. Here is an example with usage:

require_once "class.Browser.php";


echo "<pre>";
echo "<br />User Agent:      ".Browser::ua();
echo "<br />Browser Id:      ".Browser::id();
echo "<br />Browser Name:    ".Browser::name();
echo "<br />Browser Version: ".Browser::version();
echo "<br />OS:              ".Browser::os();
echo "<br />Device:          ".Browser::device();
echo "<br />Platform:        ".Browser::platform();
echo "<br />Is PC:           ".yesno(Browser::isPc());
echo "<br />Is Windows:      ".yesno(Browser::isWindows());
echo "<br />Is Mac:          ".yesno(Browser::isMac());
echo "<br />Is Linux:        ".yesno(Browser::isLinux());
echo "<br />Is Symbian:      ".yesno(Browser::isSymbian());
echo "<br />Is IE:           ".yesno(Browser::isIe());
echo "<br />Is Safari:       ".yesno(Browser::isSafari());
echo "<br />Is Firefox:      ".yesno(Browser::isFirefox());
echo "<br />Is Chrome:       ".yesno(Browser::isChrome());
echo "<br />Is Opera:        ".yesno(Browser::isOpera());
echo "<br />Is iPhone:       ".yesno(Browser::isIphone());
echo "<br />Is Handlheld:    ".yesno(Browser::isHandheld());
echo "<br />Is Phone:        ".yesno(Browser::isPhone());
echo "<br />Is Console:      ".yesno(Browser::isConsole());
echo "<br />Is Terminal:     ".yesno(Browser::isTerminal());
echo "</pre>";

Class file as well as example file you can download here. In case you figure out any problem or bug please leave your comment with bug description here.

4 thoughts to “Browser Class by Bluesman”

  1. insert to line 341:

    elseif (strpos(“$user_agent”, “android 2.1”) !== false) { return self::setOs (‘Android 2.1’, ‘phone’, ‘handheld’); }
    elseif (strpos(“$user_agent”, “android 2.2”) !== false) { return self::setOs (‘Android 2.2’, ‘phone’, ‘handheld’); }
    elseif (strpos(“$user_agent”, “android”) !== false) { return self::setOs (‘Android’, ‘phone’, ‘handheld’); }

  2. Opera/9.80 (Windows NT 6.0; U; ru) Presto/2.6.30 Version/10.62

    show: Opera 9.80, but installed Opera 10.62

    code: echo Browser::name().’ ‘.Browser::version();

  3. From android user-agent:
    Mozilla/5.0 (Linux; U; Android 2.2; ru-ru; Desire_A8181 Build/FRF91) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1

Leave a Reply

Your email address will not be published. Required fields are marked *