On a Windows computer, the following script:
<?php mkdir("c:\\[test]"); file_put_contents("c:\\[test]\\test.txt", "some content"); chdir("c:\\[test]"); echo getcwd()."\n"; var_dump(glob('*')); ?>
Displays this:
C:\[test] array(0) { }
When it is expected:
C:\[test] array(1) { [0]=> string(8) "test.txt" }
I understand that glob treats parentheses as special characters found in the pattern parameter.
Sample * matches any file in the current working directory. However, glob () behaves as if it started with the c:\\[test]\\* pattern
The brackets are then interpreted as part of the pattern, when in fact they are part of the directory.
Does glob intend to consider the path as part of the pattern? I would prefer it to use the current directory as a starting point, and then only process the template.
(Attempt to generalize): The glob function acts as if it receives c:\\[test]\\* as a matching pattern and tries to match either c:\t\* , c:\e\* or c:\s\* . But the pattern is really * , and he should not try to match this.
source share