There is a predefined constant PHP_OS that will help, but only displays the OS on which PHP was built in, and not the OS on which it runs.
php_uname is what you want to know about the current server your code is running on:
php_uname () returns a description of the operating system that PHP is running on.
In particular,
php_uname('s');
source share