Skip to content

Instantly share code, notes, and snippets.

@mihai-vlc
Created June 23, 2013 20:34
Show Gist options
  • Save mihai-vlc/5846443 to your computer and use it in GitHub Desktop.
Save mihai-vlc/5846443 to your computer and use it in GitHub Desktop.
PHP: get os
<?php
function get_os() {
$browser = $_SERVER['HTTP_USER_AGENT'];
if (strpos($browser,"Windows") !== FALSE) {
return "Windows";
}else if (strpos($browser,"Linux") !== FALSE) {
return "Linux";
}else if (strpos($browser,"FreeBSD") !== FALSE) {
return "FreeBSD";
}else if (strpos($browser,"NetBSD") !== FALSE) {
return "NetBSD";
}else if (strpos($browser,"OSX") !== FALSE) {
return "OSX";
}else if (strpos($browser,"iOS") !== FALSE) {
return "iOS";
}else if (strpos($browser,"Android") !== FALSE) {
return "Linux";
}
}
echo get_os();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment