I wouldn\'t know under what keyword to look for this in the PHP database, so I\'m asking here.
Reason I want to know is because of how different Operating Systems handle
You could use the predefined constant PHP_OS.
I'm using
if (PHP_OS === 'WINNT') {...}
<?php
$OSList = array
(
// Match user agent string with operating systems
'Windows 3.11' => 'Win16',
'Windows 95' => '(Windows 95)|(Win95)|(Windows_95)',
'Windows 98' => '(Windows 98)|(Win98)',
'Windows 2000' => '(Windows NT 5.0)|(Windows 2000)',
'Windows XP' => '(Windows NT 5.1)|(Windows XP)',
'Windows Server 2003' => '(Windows NT 5.2)',
'Windows Vista' => '(Windows NT 6.0)',
'Windows 7' => '(Windows NT 7.0)',
'Windows NT 4.0' => '(Windows NT 4.0)|(WinNT4.0)|(WinNT)|(Windows NT)',
'Windows ME' => 'Windows ME',
'Open BSD' => 'OpenBSD',
'Sun OS' => 'SunOS',
'Linux' => '(Linux)|(X11)',
'Mac OS' => '(Mac_PowerPC)|(Macintosh)',
'QNX' => 'QNX',
'BeOS' => 'BeOS',
'OS/2' => 'OS/2',
'Search Bot'=>'(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp)|(MSNBot)|(Ask Jeeves/Teoma)|(ia_archiver)'
);
// Loop through the array of user agents and matching operating systems
foreach($OSList as $CurrOS=>$Match)
{
// Find a match
if (eregi($Match, $_SERVER['HTTP_USER_AGENT']))
{
// We found the correct match
break;
}
}
// You are using Windows Vista
echo "You are using ".$CurrOS;
?>
$svr_os=strtolower(reset(explode(' ',php_uname('s'))));
$isLinux=$svr_os==='linux';
$isWindows=$svr_os==='windows';
You may also want to do a php info call to have a look at a lot of the configuration settings on your PHP setup, code is simple:
phpinfo();
*"BTW, nix OS use \n as new line. Mac usees \r, Windows - \r\n"
ARRRGH! PLEASE STOP PERPETUATING THIS MYTH!
Mac OS 9 used that like 10 years ago, but no one uses OS9 anymore. MACS USE UNIX LINE ENDINGS. \n. "Mac" used today should refer to contemporary computers, just as "Windows" refers to XP or vista unless otherwise qualified.
Saying Macs use \r is about as correct as saying that "Windows runs on top of MS-DOS, supports only the FAT16 filesystem, and has no 64-bit support."
Nobody should ever ever use \r for anything under any circumstances. Unless they are targeting old-ass macs.
Check the $_SERVER variable.
echo "<pre>";
print_r($_SERVER);
You can then use strstr (or any string comparison function) to check if you are on Windows. In this example, I checked the SERVER_SIGNATURE but you can use whatever key you want.
$isWindows = strstr($_SERVER[SERVER_SIGNATURE], "Win32") !== FALSE;