1--TEST--
2Test scandir() function : usage variations - Wildcards in directory path
3--SKIPIF--
4<?php
5if (substr(PHP_OS, 0, 3) == 'WIN') {
6    die('skip.. Not valid for Windows');
7}
8?>
9--FILE--
10<?php
11/* Prototype  : array scandir(string $dir [, int $sorting_order [, resource $context]])
12 * Description: List files & directories inside the specified path
13 * Source code: ext/standard/dir.c
14 */
15
16/*
17 * Pass a directory path using wildcards as $dir argument to test how scandir() behaves
18 */
19
20echo "*** Testing scandir() : usage variations ***\n";
21
22// create the temporary directories
23$file_path = dirname(__FILE__);
24$dir_path = $file_path . "/scandir_variation6";
25$sub_dir_path = $dir_path . "/sub_dir1";
26
27mkdir($dir_path);
28mkdir($sub_dir_path);
29
30// with different wildcard characters
31
32echo "\n-- Wildcard = '*' --\n";
33var_dump( scandir($file_path . "/scandir_var*") );
34var_dump( scandir($file_path . "/*") );
35
36echo "\n-- Wildcard = '?' --\n";
37var_dump( scandir($dir_path . "/sub_dir?") );
38var_dump( scandir($dir_path . "/sub?dir1") );
39
40?>
41===DONE===
42--CLEAN--
43<?php
44$dir_path = dirname(__FILE__) . "/scandir_variation6";
45$sub_dir_path = $dir_path . "/sub_dir1";
46
47rmdir($sub_dir_path);
48rmdir($dir_path);
49?>
50--EXPECTF--
51*** Testing scandir() : usage variations ***
52
53-- Wildcard = '*' --
54
55Warning: scandir(%s/scandir_var*): failed to open dir: %s in %s on line %d
56
57Warning: scandir(): (errno %d): %s in %s on line %d
58bool(false)
59
60Warning: scandir(%s/*): failed to open dir: %s in %s on line %d
61
62Warning: scandir(): (errno %d): %s in %s on line %d
63bool(false)
64
65-- Wildcard = '?' --
66
67Warning: scandir(%s/scandir_variation6/sub_dir?): failed to open dir: %s in %s on line %d
68
69Warning: scandir(): (errno %d): %s in %s on line %d
70bool(false)
71
72Warning: scandir(%s/scandir_variation6/sub?dir1): failed to open dir: %s in %s on line %d
73
74Warning: scandir(): (errno %d): %s in %s on line %d
75bool(false)
76===DONE===
77