Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否可以在 PHP CLI 脚本中确定我在哪种 CLI 环境中?
我想自动启用对 bash 实例的颜色支持,包括原生 linux 和 MingW32/Cygwin bash,并在 Windows 命令提示符/Cmd 中禁用它(否则它看起来很难看)。
如果您有权访问$_ENV数组 [又名 php.ini 中有一个Ein variables_order],那么您应该能够读取SHELL环境变量。
$_ENV
E
variables_order
SHELL
例如:
# echo $SHELL /bin/bash # php -r 'echo $_ENV["SHELL"];' /bin/bash # php -r 'echo ini_get("variables_order");' EGPCS