php 可能的值:PHP_OS

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/738823/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 23:42:28  来源:igfitidea点击:

Possible Values For: PHP_OS

phpsuperglobals

提问by Wilco

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.

有没有地方可以找到 PHP 预定义常量的可能值列表PHP_OS?我想将此值用于系统要求检查,但需要知道如何在此变量中命名不同的操作系统。

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
  • CYGWIN_NT-5.1
  • 达尔文
  • FreeBSD
  • 用户体验
  • IRIX64
  • Linux
  • NetBSD
  • 开放式BSD
  • 太阳操作系统
  • Unix
  • WIN32
  • WINNT
  • 视窗

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

如果有人有更完整的列表,或者知道任何其他值,我很乐意听到他们!

采纳答案by phihag

PHP passes through the uname, except on Windows (WINNT)and Netware (Netware). See Wikipediafor a non-exhaustive list of values not mentioned in your question:

PHP通过 uname但在 Windows( WINNT)Netware( Netware) 上除外。有关您的问题中未提及的值的非详尽列表,请参阅维基百科

  • CYGWIN_NT-5.1
  • IRIX64
  • SunOS
  • HP-UX
  • OpenBSD (not in Wikipedia)
  • CYGWIN_NT-5.1
  • IRIX64
  • 太阳操作系统
  • 用户体验
  • OpenBSD(不在维基百科中)

回答by Nick Presta

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.

例如,有用于目录分隔符的常量、realpath() 等函数,用于处理不同操作系统上的目录。

What, specifically, are you trying to do?

具体来说,你想做什么?

回答by marz201

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.

php_uname("s")对于非 Unix 操作系统来说,似乎是一个好的开始,因为在我看来,它在 Unix 系统和 posix 子系统(例如 Cygwin、Mingw、UWin、EMX+GCC 和 MKS)上看起来uname("s")php_uname("s")相同。以下是不符合 Posix 的开箱即用且运行 PHP 的操作系统列表。

OS

操作系统

  • OS/2 Warp
  • eComStation
  • RISC OS
  • Windows XP 64-bit
  • OS/2 扭曲
  • 电子通讯站
  • RISC操作系统
  • Windows XP 64 位

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.

请记住,这根本不是用于浏览器检测,而是用于根路径检测、可能是也可能不是\和的目录分隔符/、EOL 以及其他一些东西。

Examples of root paths

根路径示例

  • Unix\linux\Mac OS X: /
  • OS/2: C:\
  • Amiga: dh0:
  • Unix\linux\Mac OS X: /
  • 操作系统/2: C:\
  • 阿米加: dh0: