|Possible Values For: PHP_OS||#1|
Is there a place to find a list of the possible values for the PHP predefined constant
? 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:
If anyone has a more complete list, or knows of any additional values I(d love to hear them!
posted date: 2009-04-10 12:51:00
|Re: Possible Values For: PHP_OS||#3|
PHP passes through the uname, except on Windows (
) and Netware (
). See Wikipedia for a non-exhaustive list of values not mentioned in your question:CYGWIN_NT-5.1IRIX64SunOSHP-UXOpenBSD (not in Wikipedia)
posted date: 2009-04-10 13:14:00
|Re: Possible Values For: PHP_OS||#4|
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?
posted date: 2009-04-10 13:15:00
|Re: Possible Values For: PHP_OS||#5|
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.
posted date: 2009-04-10 13:17:00
|Re: Possible Values For: PHP_OS||#6|
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.
posted date: 2009-04-10 13:41:00
|Re: Possible Values For: PHP_OS||#7|
@NickPresta, example (and real world) scenario: locale codes for
differ greatly in Windows (see msdn.microsoft.com/en-us/library/39cwe7zf%28vs.71%29.aspx). You need to know your OS in order to call
properly. Even then, as you imply, this feels like a very awkward solution.
posted date: 2012-06-07 16:17:00
|Re: Possible Values For: PHP_OS||#8|
it seems like the php_uname("s") for non-Unix OSes would eb 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.OSOS/2 Warp eComStation RISC OSWindows XP 64-bitKeep 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 pathsUnix\linux\Mac OS X: /OS/2: C:\Amiga: dh0:
posted date: 2013-06-20 16:58:00
|Re: Possible Values For: PHP_OS||#9|
+1, but I need OS checking because the PCRE stack size varies greatly from Windows to Linux (256KB vs. 8MB), so I need to do an
on Windows to limit recursion (to avoid a segfault). Ugly, but yeah... it's PHP we're talking about.
posted date: 2013-10-31 16:13:00
|Re: Possible Values For: PHP_OS||#10|
This is wrong. On Windows 7
php_uname('s') == "Windows NT"
PHP_OS == "WINNT"
, neiter is mentioned on that Wikipedia page.
posted date: 2016-05-26 19:33:00
|Re: Possible Values For: PHP_OS||#11|
@AndreKR Windows is one exception. Note that I'm answering the question by @Wilco, which asked for additional values, and already mentioned
. Nevertheless, I've updated the answer and linked to the source code which proves that
is being used.
posted date: 2016-05-26 23:13:00
|select page: « 1 »|