Created
June 23, 2013 20:34
-
-
Save mihai-vlc/5846443 to your computer and use it in GitHub Desktop.
PHP: get os
This file contains 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
<?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