1--TEST--
2Test glob() function: basic functions
3--FILE--
4<?php
5/* Prototype: array glob ( string $pattern [, int $flags] );
6   Description: Find pathnames matching a pattern
7*/
8
9echo "*** Testing glob() : basic functions ***\n";
10
11$file_path = dirname(__FILE__);
12
13// temp dirname used here
14$dirname = "$file_path/glob_basic";
15
16// temp dir created
17mkdir($dirname);
18
19// temp files created
20$fp = fopen("$dirname/wonder12345", "w");
21fclose($fp);
22$fp = fopen("$dirname/wonder.txt", "w");
23fclose($fp);
24$fp = fopen("$dirname/file.text", "w");
25fclose($fp);
26
27// glob() with default arguments
28sort_var_dump( glob($dirname."/*") );
29sort_var_dump( glob($dirname."/*.txt") );
30sort_var_dump( glob($dirname."/*.t?t") );
31sort_var_dump( glob($dirname."/*.t*t") );
32sort_var_dump( glob($dirname."/*.?") );
33sort_var_dump( glob($dirname."/*.*") );
34
35echo "Done\n";
36
37function sort_var_dump($results) {
38   sort($results);
39   var_dump($results);
40}
41?>
42--CLEAN--
43<?php
44$file_path = dirname(__FILE__);
45unlink("$file_path/glob_basic/wonder12345");
46unlink("$file_path/glob_basic/wonder.txt");
47unlink("$file_path/glob_basic/file.text");
48rmdir("$file_path/glob_basic/");
49?>
50--EXPECTF--
51*** Testing glob() : basic functions ***
52array(3) {
53  [0]=>
54  string(%d) "%s/glob_basic/file.text"
55  [1]=>
56  string(%d) "%s/glob_basic/wonder.txt"
57  [2]=>
58  string(%d) "%s/glob_basic/wonder12345"
59}
60array(1) {
61  [0]=>
62  string(%d) "%s/glob_basic/wonder.txt"
63}
64array(1) {
65  [0]=>
66  string(%d) "%s/glob_basic/wonder.txt"
67}
68array(2) {
69  [0]=>
70  string(%d) "%s/glob_basic/file.text"
71  [1]=>
72  string(%d) "%s/glob_basic/wonder.txt"
73}
74array(0) {
75}
76array(2) {
77  [0]=>
78  string(%d) "%s/glob_basic/file.text"
79  [1]=>
80  string(%d) "%s/glob_basic/wonder.txt"
81}
82Done
83