1--TEST--
2Test scandir() function : usage variations - different file names
3--FILE--
4<?php
5/* Prototype  : array scandir(string $dir [, int $sorting_order [, resource $context]])
6 * Description: List files & directories inside the specified path
7 * Source code: ext/standard/dir.c
8 */
9
10/*
11 * Pass a directory containing files with different types of names to test how scandir()
12 * reads them
13 */
14
15echo "*** Testing scandir() : usage variations ***\n";
16
17$dir_path = dirname(__FILE__) . "/scandir_variation8/";
18mkdir($dir_path);
19
20// heredoc string
21$heredoc = <<<EOT
22hd_file
23EOT;
24
25$inputs = array(
26
27       // int data
28/*1*/  0,
29       1,
30       12345,
31       -2345,
32
33       // float data
34/*5*/  10.5,
35       -10.5,
36       12.3456789000e10,
37       12.3456789000E-10,
38       .5,
39
40       // empty data
41/*10*/ "",
42       array(),
43
44       // string data
45/*12*/ "double_file",
46       'single_file',
47       $heredoc,
48);
49
50$iterator = 1;
51foreach($inputs as $key => $input) {
52	echo "\n-- Iteration $iterator --\n";
53	$handle = "fp{$iterator}";
54	var_dump( $$handle = fopen(@"$dir_path$input.tmp", 'w') );
55	fclose($$handle);
56	$iterator++;
57};
58
59echo "\n-- Call to scandir() --\n";
60var_dump($content = scandir($dir_path));
61
62// remove all files in directory so can remove directory in CLEAN section
63foreach ($content as $file_name) {
64	// suppress errors as won't be able to remove "." and ".." entries
65	@unlink($dir_path . $file_name);
66}
67?>
68===DONE===
69--CLEAN--
70<?php
71$dir_path = dirname(__FILE__) . "/scandir_variation8";
72rmdir($dir_path);
73?>
74--EXPECTF--
75*** Testing scandir() : usage variations ***
76
77-- Iteration 1 --
78resource(%d) of type (stream)
79
80-- Iteration 2 --
81resource(%d) of type (stream)
82
83-- Iteration 3 --
84resource(%d) of type (stream)
85
86-- Iteration 4 --
87resource(%d) of type (stream)
88
89-- Iteration 5 --
90resource(%d) of type (stream)
91
92-- Iteration 6 --
93resource(%d) of type (stream)
94
95-- Iteration 7 --
96resource(%d) of type (stream)
97
98-- Iteration 8 --
99resource(%d) of type (stream)
100
101-- Iteration 9 --
102resource(%d) of type (stream)
103
104-- Iteration 10 --
105resource(%d) of type (stream)
106
107-- Iteration 11 --
108resource(%d) of type (stream)
109
110-- Iteration 12 --
111resource(%d) of type (stream)
112
113-- Iteration 13 --
114resource(%d) of type (stream)
115
116-- Iteration 14 --
117resource(%d) of type (stream)
118
119-- Call to scandir() --
120array(16) {
121  [0]=>
122  string(9) "-10.5.tmp"
123  [1]=>
124  string(9) "-2345.tmp"
125  [2]=>
126  string(1) "."
127  [3]=>
128  string(2) ".."
129  [4]=>
130  string(4) ".tmp"
131  [5]=>
132  string(7) "0.5.tmp"
133  [6]=>
134  string(5) "0.tmp"
135  [7]=>
136  string(17) "1.23456789E-9.tmp"
137  [8]=>
138  string(5) "1.tmp"
139  [9]=>
140  string(8) "10.5.tmp"
141  [10]=>
142  string(9) "12345.tmp"
143  [11]=>
144  string(16) "123456789000.tmp"
145  [12]=>
146  string(9) "Array.tmp"
147  [13]=>
148  string(15) "double_file.tmp"
149  [14]=>
150  string(11) "hd_file.tmp"
151  [15]=>
152  string(15) "single_file.tmp"
153}
154===DONE===
155