Created
October 16, 2011 05:18
-
-
Save jehoshua02/1290536 to your computer and use it in GitHub Desktop.
Rework of BrowserInformation class using class variables correctly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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