A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2009 yearPossible Values For: PHP_OS - page 1
User InfoPosts
Possible Values For: PHP_OS#1
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!

posted date: 2009-04-10 12:51:00


Re: Possible Values For: PHP_OS#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2009-04-10 12:51:01


Re: Possible Values For: PHP_OS#3
PHP passes through the uname, except on Windows (WINNT) and Netware (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 setlocale() 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 setlocale() 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 ini_set 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" and 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 WINNT. Nevertheless, I've updated the answer and linked to the source code which proves that uname is being used.

posted date: 2016-05-26 23:13:00


select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.