Welcome to WebmasterWorld Guest from 54.196.153.46

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Detect the server's OS

     
5:15 pm on Aug 7, 2007 (gmt 0)

Junior Member

10+ Year Member

joined:Dec 7, 2004
posts:88
votes: 0


Hi,
Is there some function to guess if the server is running under Linux or Windows? Thanks!
5:22 pm on Aug 7, 2007 (gmt 0)

Preferred Member

5+ Year Member

joined:Jan 16, 2007
posts:477
votes: 0


try this
echo $_SERVER['SERVER_SOFTWARE'];
1:44 pm on Aug 8, 2007 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member whoisgregg is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Dec 9, 2003
posts:3416
votes: 0


Anytime you need to know something about the server that is running PHP, check out the predefined variables manual page [php.net]. :)
1:53 pm on Aug 9, 2007 (gmt 0)

Administrator

WebmasterWorld Administrator coopster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:July 31, 2003
posts:12541
votes: 1


For server OS there is also the predefined constants [php.net]. I often use this for determining between Windows and all others:
if (stristr [php.net](PHP_OS, 'WIN')) { 
// Win
} else {
// Other
}