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