如何在 PHP 中正确拆分 PATH 变量?
我要分手
$path = getenv('PATH');
到它的组件中.如何以依赖于操作系统的方式确定分隔符?
into its components. How do I determine the separator char in an os-dependent fashion?
推荐答案
您可以使用 PATH_SEPARATOR 常量,然后根据需要使用 DIRECTORY_SEPARATOR 常量来分割路径.请参阅 目录预定义常量
You can use the PATH_SEPARATOR constant, then the DIRECTORY_SEPARATOR constant to split the path if needed.
See Directory Predefined Constants
相关文章