Sometimes it is necessary to detect the operating system on which your php code is running. PHP has number of pre defined variables and PHP_OS is one such variable which is an string containing the operating system name.
So following code checks whether the system is running on windows or not.
if (stristr(PHP_OS, 'WIN')) {
echo "Win32";
}
What if the operating system is named "DARWIN".
ReplyDeleteDARWIN refers to macs
ReplyDeleteWhen I want to detect the OS, I use
ReplyDeleteif(stristr($_SERVER['SERVER_SOFTWARE'], 'Win32'))
$slash = '\\';
else
$slash = '/';
This is the easiest solution I've found on the web. I just did a if...else...to serve Mac related ads to visitors with mac
ReplyDeleteok
ReplyDeleteDoesn't that just tell you what software the server is running rather than the end user?
ReplyDeletephp_uname('s') is more correct that PHP_OS
ReplyDelete