PHP glob() in bracketed directories

前提是你 提交于 2019-12-03 14:43:45

This seems to be covered as an issue in this bug report on php.net: https://bugs.php.net/bug.php?id=33047

The last post on that thread is about it not being a bug, but an issue from how glob treats brackets, as part of the regular expression. I'm not sure I agree. It seems you can work around this, unless you cannot move up into the parent folder.

If you remove the first requirement of being in the inside [test] folder, you can get the file listing by using a syntax like below:

chdir('..');
$glob = glob("[[]test[]]/*");

Given these complications, I would recommend not using the glob function if you are running into issues on windows machines, and look at other file listing functions like readdir.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!