目录结构如下myfoldera.txt[myfolder]a.txt代码:$files=glob('myfolder/a.txt');var_dump($files);$files=glob('[myfolder]/a.txt');var_dump($files);//[]使用时需要转义$files=glob('\[myfolder\]/a.txt');var_dump($文件);windows下输出test.php:7:array(1){[0]=>string(14)"myfolder/a.txt"}test.php:14:array(0){}test.php:21:array(0){}linux输出test.php:7:array(1){[0]=>string(14)"myfolder/a.txt"}test.php:14:array(0){}test.php:21:array(1){[0]=>string(16)"[myfolder]/a.txt"}无论是windows还是linux,[]都是目录中的一个普通字符。为什么在windows下不能匹配呢?我们去php源码里找PHP_FUNCTION(glob),找到关键代码PHP_FUNCTION(glob){...if(0!=(ret=glob(pattern,flags&GLOB_FLAGMASK,NULL,&globbuf))){。..}继续找到glob方法的定义#ifndefPHP_WIN32#include
