I have a script which I want to run on windows under Cygwin and on Linux. I have to make distinction between the two running environment for some purposes. What is the best way to do it?
PHP_OS displays the OS that PHP was BUILT on, not the current OS.
meagar
2010-02-02 14:56:20
if its built on the OS that PHP is also running on, then its fine. NOte in the docs of php_uname(), there are some caveats as well.
ghostdog74
2010-02-02 15:02:42
PHP_OS is not even a variable.
Flavius
2010-02-02 15:03:40
+5
A:
There is a pre-defined constant PHP_OS which will help, but only displays the OS that PHP was built on, not the OS it is running on.
php_uname
is what you want to discover information about the current server running your code:
php_uname() returns a description of the operating system PHP is running on.
http://php.net/manual/en/function.php-uname.php
Specifically,
php_uname('s'); // Operating system name. eg. FreeBSD.
meagar
2010-02-02 14:52:31