Possible Values For: PHP_OS

PhpSuperglobals

Php Problem Overview


Is there a place to find a list of the possible values for the PHP predefined constant PHP_OS ? I'd like to use this value for a system requirements check, but need to know how different operating systems are named in this variable.

Through some searching, so far I've compiled the following list:

  • CYGWIN_NT-5.1
  • Darwin
  • FreeBSD
  • HP-UX
  • IRIX64
  • Linux
  • NetBSD
  • OpenBSD
  • SunOS
  • Unix
  • WIN32
  • WINNT
  • Windows

If anyone has a more complete list, or knows of any additional values I'd love to hear them!

Php Solutions


Solution 1 - Php

PHP passes through the uname, except on Windows (WINNT) and Netware (Netware). See http://en.wikipedia.org/wiki/Uname#Table_of_standard_uname_output">Wikipedia</a> for a non-exhaustive list of values not mentioned in your question:

  • CYGWIN_NT-5.1
  • IRIX64
  • SunOS
  • HP-UX
  • OpenBSD (not in Wikipedia)

Solution 2 - Php

I think a better solution to do a 'requirement check' would be to actually use things that you need to know work properly and see what happens.

For example, there are constants for directory separators, functions like realpath(), etc to deal with directories on different operating systems.

What, specifically, are you trying to do?

Solution 3 - Php

it seems like the php_uname("s") for non-Unix OSes would be a good start, since it looks to me like uname("s") and php_uname("s") are the same on Unix systems and posix sub systems, such as Cygwin, Mingw, UWin, EMX+GCC, and MKS. Below is a list of OSes that are not Posix-compliant out of the box and that run PHP. OS

  • OS/2 Warp
  • eComStation
  • RISC OS
  • Windows XP 64-bit

Keep in mind, this is not at all for Browser detection, but root path detecting, directory separators that may or may not be \ and /, EOL, and a few other things.

Examples of root paths

  • Unix\linux\Mac OS X: /
  • OS/2: C:\
  • Amiga: dh0:

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionWilcoView Question on Stackoverflow
Solution 1 - PhpphihagView Answer on Stackoverflow
Solution 2 - PhpNick PrestaView Answer on Stackoverflow
Solution 3 - Phpmarz201View Answer on Stackoverflow