Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/291.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.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 Opendir()包含空格的路径_Php - Fatal编程技术网

PHP Opendir()包含空格的路径

PHP Opendir()包含空格的路径,php,Php,我想使用opendir PHP函数在linux文件系统上打开一个目录 路径可能包含空格或其他一些特殊字符 当我试图打开目录时,我得到: Warning: opendir(/home/user/_demo/test/salamis\ test): failed to open dir: No such file or directory 我首先尝试使用\斜杠空格替换空格字符,使用: str_replace(" ","\ ","salamis test"); 但不幸的是,这种方法不起作用。有什么

我想使用opendir PHP函数在linux文件系统上打开一个目录

路径可能包含空格或其他一些特殊字符

当我试图打开目录时,我得到:

Warning: opendir(/home/user/_demo/test/salamis\ test): failed to open dir: No such file or directory
我首先尝试使用\斜杠空格替换空格字符,使用:

str_replace(" ","\ ","salamis test");

但不幸的是,这种方法不起作用。有什么建议吗

将路径参数括在双引号或单引号内

e、 g


将路径参数括在双引号或单引号内

e、 g


今天也有同样的问题。我发现添加引号没有帮助。我意识到共享文件夹是用不同的用户帐户装载的,在使用正确的uid和gid apache装载和更新/etc/fstab之后,我能够装载和处理共享上的文件


也很有帮助。

今天也有同样的问题。我发现添加引号没有帮助。我意识到共享文件夹是用不同的用户帐户装载的,在使用正确的uid和gid apache装载和更新/etc/fstab之后,我能够装载和处理共享上的文件


也很有帮助。

您尝试过opendir/home/user/_demo/test/salamis test?您是否尝试过opendir/home/user/_demo/test/salamis test?如果他没有用引号括住该路径,他将得到一个解析错误。脚本甚至不会运行。@webbiedave我猜他在spaces.Necro-commenting之前包含了“\”,但这不是解决方案。这并不能解决这个问题。如果他没有用引号括住那个路径,他会得到一个解析错误。脚本甚至不会运行。@webbiedave我猜他在spaces.Necro-commenting之前包含了“\”,但这不是解决方案。它不能解决这个问题。
opendir('/home/user/_demo/test/salamis test');
opendir("/home/user/_demo/test/salamis test");

$path = '/home/user/_demo/test/salamis test';
opendir($path);

$path = "/home/user/_demo/test/salamis test";
opendir($path);