Get server operating system in PHP

Posted in Programming  
E-Mail This Post/Page   

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.

PHP:
  1. function operating_system()
  2. /*    Returns 'win' for a Windows server, 'linux' for others    */
  3. {
  4. $os_string = php_uname('s');
  5. if (strpos(strtoupper($os_string), 'WIN')!==false)
  6. {
  7. return 'win';
  8. }
  9. else
  10. {
  11. return 'linux';
  12. }
  13. }

PHPInfo - Or, how to tell more about your server than you want to know
Microsoft Longhorn scheduled for late 2005
I locked myself out of SSH
Hey, I’m back
Microsoft considering releasing more source code

Leave a Comment