import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-file / glob_variation.php
blob7d29e91d9eeb2d796041c505b4a1c943662df5f2
1 <?php
2 /* Prototype: array glob ( string $pattern [, int $flags] );
3 Description: Find pathnames matching a pattern
4 */
6 echo "*** Testing glob() : usage variations ***\n";
8 $file_path = dirname(__FILE__);
10 // temp dir created
11 mkdir("$file_path/glob_variation");
12 mkdir("$file_path/glob_variation/wonder");
14 // temp files created
15 $fp = fopen("$file_path/glob_variation/wonder12345", "w");
16 fclose($fp);
17 $fp = fopen("$file_path/glob_variation/wonder;123456", "w");
18 fclose($fp);
20 $patterns = array (
21 "$file_path/glob_variation/*der*",
22 "$file_path/glob_variation/?onder*",
23 "$file_path/glob_variation/w*der?*",
24 "$file_path/glob_variation/*der5",
25 "$file_path/glob_variation/??onder*",
26 "$file_path/glob_variation/***der***",
27 "$file_path/glob_variation/++onder*",
28 "$file_path/glob_variation/WONDER5\0",
29 '$file_path/glob_variation/wonder5',
30 "$file_path/glob_variation/?wonder?",
31 "$file_path/glob_variation/wonder?",
32 TRUE // boolean true
34 $counter = 1;
35 /* loop through $patterns to match each $pattern with the files created
36 using glob() */
37 foreach($patterns as $pattern) {
38 echo "\n-- Iteration $counter --\n";
39 var_dump( glob($pattern) ); // default arguments
40 var_dump( glob($pattern, GLOB_MARK) );
41 var_dump( glob($pattern, GLOB_NOSORT) );
42 var_dump( glob($pattern, GLOB_NOCHECK) );
43 var_dump( glob($pattern, GLOB_NOESCAPE) );
44 var_dump( glob($pattern, GLOB_ERR) );
45 $counter++;
48 echo "\n*** Testing glob() with pattern within braces ***\n";
49 var_dump( glob("$file_path/glob_variation/*{5}", GLOB_BRACE) );
51 // delete temp files and dir
52 unlink("$file_path/glob_variation/wonder12345");
53 unlink("$file_path/glob_variation/wonder;123456");
54 rmdir("$file_path/glob_variation/wonder");
55 rmdir("$file_path/glob_variation");
57 echo "\n*** Testing glob() on directories ***\n";
58 // temp dir created to check for pattern matching the sub dir created in it
59 mkdir("$file_path/glob_variation/wonder1/wonder2", 0777, true);
61 $counter = 1;
62 /* loop through $patterns to match each $pattern with the directories created
63 using glob() */
64 foreach($patterns as $pattern) {
65 echo "-- Iteration $counter --\n";
66 var_dump( glob($pattern, GLOB_ONLYDIR) );
67 $counter++;
70 echo "Done\n";
71 ?><?php
72 $file_path = dirname(__FILE__);
73 rmdir("$file_path/glob_variation/wonder1/wonder2");
74 rmdir("$file_path/glob_variation/wonder1/");
75 rmdir("$file_path/glob_variation/");