File: glob_basic.phpt

package info (click to toggle)
php5 5.2.6.dfsg.1-1%2Blenny16
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 81,956 kB
  • ctags: 45,717
  • sloc: ansic: 545,818; sh: 18,463; php: 12,555; xml: 4,362; yacc: 2,430; lex: 2,294; makefile: 1,193; tcl: 1,128; awk: 693; cpp: 682; perl: 71; pascal: 24; sql: 22
file content (77 lines) | stat: -rwxr-xr-x 1,596 bytes parent folder | download
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
--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 = dirname(__FILE__);

// 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
var_dump( glob($dirname."/*") );
var_dump( glob($dirname."/*.txt") );
var_dump( glob($dirname."/*.t?t") );
var_dump( glob($dirname."/*.t*t") );
var_dump( glob($dirname."/*.?") );
var_dump( glob($dirname."/*.*") );

echo "Done\n";
?>
--CLEAN--
<?php
$file_path = dirname(__FILE__);
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