Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何获取Linux系统的特定路径_Php_Linux - Fatal编程技术网

Php 如何获取Linux系统的特定路径

Php 如何获取Linux系统的特定路径,php,linux,Php,Linux,我已经在windows机器上开发了代码,所以代码如下 如果(!file_存在('C:/xampp/htdocs/Collector/config_manifest.ini')){ $ec->writeErrorMessage(“未找到清单配置文件”); 出口 } 移动到Linux系统的代码和我通过FTP找到的路径是/var/www/html/php/Collector/config\u manifest。在中,现在如何在文件中写入此代码\u在php中存在以了解该文件是否存在?您只需将新路径放在

我已经在windows机器上开发了代码,所以代码如下

如果(!file_存在('C:/xampp/htdocs/Collector/config_manifest.ini')){
$ec->writeErrorMessage(“未找到清单配置文件”);
出口
}

移动到Linux系统的代码和我通过FTP找到的路径是
/var/www/html/php/Collector/config\u manifest。在
中,现在如何在
文件中写入此代码\u在php中存在
以了解该文件是否存在?

您只需将新路径放在旧路径所在的位置

if (!file_exists('/var/www/html/php/Collector/config_manifest.in'))
看看这个常数。最大的好处是,这个常量是独立于操作系统的,所以它可以在Linux、Windows、macOS和几乎所有其他运行PHP的东西上工作

if (!file_exists(__DIR__ . '/relative/path/to/config_manifest.ini')

我不需要放置var/www/html/php/collector吗?不,它是一个相对文件路径。好的,但在某些地方我有这样的代码$info\u array=parse\u ini\u文件('C:/xampp/htdocs/Collector/config\u manifest.ini',true)$info_array=parse_ini_文件('C:/xampp/htdocs/Collector/config_manifest.ini',true);如何更改这些?使用键盘。查一下你做这些陈述的文件,然后像我在回答中所做的那样修改它们。可能是沿着
\uuuuuu DIR\uuuuuuuuuuuuuuuuuu'的路线/Collector/config_manifest.ini“
就像在C中一样,它从C开始:/xamp那么你认为如果我从var/www开始,它会工作吗?@NiteshSharma-它从
/
开始!