detecting operating system where php is installed

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
dickey
Forum Commoner
Posts: 50
Joined: Thu May 16, 2002 8:04 pm
Location: Sydney, Australia

detecting operating system where php is installed

Post 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
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

predefined constant PHP_OS I dont recall if it is in any superglobal..

echo 'My OS is '.PHP_OS.'!<br>'."\n";
dickey
Forum Commoner
Posts: 50
Joined: Thu May 16, 2002 8:04 pm
Location: Sydney, Australia

Thanks Jon

Post by dickey »

Thanks Jon
Post Reply