Page 1 of 1

detecting operating system where php is installed

Posted: Sun Jun 29, 2003 8:49 pm
by dickey
what is the best way to reliably attain which operating system any version of PHP is installed under, and store it as a variable.

I'm assuming you read an environment variable from phpinfo that is common to both unix/linux/windows versions of php.

e.g. $_ENV["OS"]; works fine under windows but is not present in the linux implementation of PHP

Maybe you read the values of phpinfo(2) 'general' and find the value of system in the array.

Any suggestions will be appreciated.

Andrew

Posted: Sun Jun 29, 2003 10:49 pm
by Stoker
predefined constant PHP_OS I dont recall if it is in any superglobal..

echo 'My OS is '.PHP_OS.'!<br>'."\n";

Thanks Jon

Posted: Sun Jun 29, 2003 11:17 pm
by dickey
Thanks Jon