views:

1181

answers:

2

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!

+1  A: 

PHP passes through the uname. See Wikipedia for possible values:

  • CYGWIN_NT-5.1
  • IRIX64
  • SunOS
  • HP-UX
  • OpenBSD (not in Wikipedia)
phihag
+2  A: 

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?

Nick Presta
That certainly makes sense, but I'm trying to run a check on operating systems my script has been tested on. In that case, I only really need a subset of the possible values, but a full list could prove useful.
Wilco
It is your choice. I just want to point out that in the future, other values could crop up (WIN64 perhaps), so you will need to check for those periodically.
Nick Presta