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