Skip to content

Instantly share code, notes, and snippets.

@jehoshua02
Created October 16, 2011 05:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jehoshua02/1290536 to your computer and use it in GitHub Desktop.
Save jehoshua02/1290536 to your computer and use it in GitHub Desktop.
Rework of BrowserInformation class using class variables correctly
class BrowserInformation
{
private $agent;
private $browser;
public function __construct($agent = NULL)
{
if (empty($agent))
{
$agent = $_SERVER['HTTP_USER_AGENT'];
}
$this->agent = $agent;
$this->browser = get_browser($agent, true);
}
public function platform()
{
$platform = $this->browser['platform'];
//unknown check
if ($platform === "unknown")
{
echo "IDK what OS you'r running<br />";
}
else
{
echo "You are on {$platform}<br />";
}
}
}
$client = new BrowserInformation();
$client->platform();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment