I searched for quite a while now, but i could not find a definite answer to the question wether the constant PHP_OS contains the OS php was built on or runs on.
The php documentation of php_uname (http://php.net/manual/de/function.php-uname.php) states:
"For the name of just the operating system, consider using the PHP_OS constant, but keep in mind this constant will contain the operating system PHP was built on. "
However, on the very same page there is a comment from 2006 stating:
"Contrary to the last note, PHP_OS does display the OS PHP runs on currently, [...] This has nothing to do with the system PHP was built on."
I could not find any definite answer anywhere on the web regarding this question (topis about php_uname and PHP_OS mostly only cover os detection and similar topics). What's right now - the documentation or the comment?
The pear-core package uses PHP_OS to determine wether it's running on Unix-like systems or on windows, so is it safe to assume the documentation is indeed wrong?
I had a look at the source code. The configure script does this:
PHP_OS=`uname | xargs` AC_DEFINE_UNQUOTED(PHP_OS,"$PHP_OS",[uname output])
main.c does this:
char *php_os; php_os=PHP_OS; REGISTER_MAIN_STRINGL_CONSTANT("PHP_OS", php_os, strlen(php_os), CONST_PERSISTENT | CONST_CS);
which means that
PHP_OS in PHP is what was in
php_os in the C code, which is what was #defined by the header file constructed by the configure script, which is determined by running
uname at configuration time.
So, it's the system you were built on, not the system you were running on.
There's some special-cased code for Windows:
WIN32 is defined. But, again, this is at build time, not at run time, even if you manage to compile on Unix and run on Windows or vice versa.