Get server operating system in PHP

This function returns ‘win’ if running on a Windows server and ‘linux’ if not running on a Windows server. It should be pretty easy to extend it to match other server operating systems, but this is all I needed.

function operating_system()
/*    Returns 'win' for a Windows server, 'linux' for others    */
{
$os_string = php_uname('s');
if (strpos(strtoupper($os_string), 'WIN')!==false)
{
return 'win';
}
else
{
return 'linux';
}
}
This entry was posted in Programming. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

One Response to Get server operating system in PHP