Phar://流包装器,文件名中带有空格 [英] Phar:// stream wrapper with space in the filename
问题描述
所以我的目录中有一个zip文件
/pathdodir/zip文件.zip
所以我这样做:
$ dir ='phar:///pathdodir/zip文件.zip';$ file = scandir($ dir);print_r($ file);
但这最终导致抱怨
无法打开目录:phar错误:无效的URL或不存在的phar"
如果我重命名该zip文件,尽管它没有空格,即重命名为thezipfile.zip,然后也将$ dir更改为thezipfile.zip,则phar将起作用,并且它将相应地打印该zip中的文件.../p>
如何使phar即使文件名中有空格也能正常工作?
您使用的文件名- phar:///pathdodir/zip文件.zip
-是一个URL;它具有模式( phar://
).
您必须对URL中的特殊字符进行url编码,并且空格被编码为%20
.
so I have a zip file in directory
/pathdodir/the zip file.zip
so I do this:
$dir = 'phar:///pathdodir/the zip file.zip';
$file = scandir($dir);
print_r($file);
but then this ends up complaining about
"failed to open dir: phar error: invalid url or non-existent phar"
if I rename the zip file such that it has without spaces though ie to thezipfile.zip and then change $dir to thezipfile.zip as well, phar would work and it would print_r the files inside that zip accordingly...
how do I make it so that phar would also work even if there are spaces in the filename?
The file name you use - phar:///pathdodir/the zip file.zip
- is an URL; it has a schema (phar://
).
You have to url-encode special characters in URLs, and the space is encoded as %20
.
这篇关于Phar://流包装器,文件名中带有空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!