2017 © Pedro Peláez
 

library browser

A small class to detect the browser and the operating system

image

invoke/browser

A small class to detect the browser and the operating system

  • Friday, November 18, 2016
  • by invokemedia
  • Repository
  • 8 Watchers
  • 1 Stars
  • 19 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Browser

A very simple class that takes in a user agent string and returns the browser name (Firefox, Chrome, Opera, etc.) and also the Operating System (Mac, Windows, Android, etc.)., (*1)

Reasons

Firstly, you should not use browser sniffing for fearture detection, use Modernizr., (*2)

We mainly use this for style tweaks between different browsers. Or sometimes you may need to add a little script (differences in keystroke handling can be difficult to feature detect) or tweak on a specific platform combination and so you might do a check to see if that makes sense., (*3)

The results are pretty crude. We only return internet-explorer if any verison of IE is found. There is no version information., (*4)

For the platform, we only return that operation system. This means all iOS devices (iPad, iPhone, iPod) would only return ios., (*5)

If you need to know specifics about the device, use media queries., (*6)

Support

Platforms, (*7)

  • Linux
  • iOS
  • Mac
  • Windows
  • Android
  • Blackberry

Browsers, (*8)

  • MSIE
  • UC Browser
  • Trident
  • Vivaldi
  • Firefox
  • Chrome
  • Opera
  • Opera Mini
  • Safari

Usage

Methods

getBrowser() // returns the string for the browser
getPlatform() // returns the platform for the browser
isMobile() // returns true for android and ios platforms (except iPad)
isDesktop() // returns the opposite of isMobile()

Properties




  
  Browser Class
  


</body>
</html>

Results for Chrome on a Macbook:, (*9)

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>Browser Class</title>
  <style>
    /* the body would now be red */
    body.google-chrome.mac {
      background: red;
    }
  </style>
</head>
<body class="google-chrome mac">
  <!-- content -->
</body>
</html>

The Versions

18/11 2016

dev-master

9999999-dev

A small class to detect the browser and the operating system

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

by Invoke Media

php platform browser useragent os agent sniff

18/11 2016

1.0.0

1.0.0.0

A small class to detect the browser and the operating system

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

by Invoke Media

php platform browser useragent os agent sniff