1--TEST-- 2Test scandir() function : usage variations - different sorting constants 3--SKIPIF-- 4<?php 5if (substr(PHP_OS, 0, 3) != 'WIN') { 6 die("skip Valid only on 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 16printf("SCANDIR_SORT_ASCENDING: %d\n", SCANDIR_SORT_ASCENDING); 17printf("SCANDIR_SORT_DESCENDING: %d\n", SCANDIR_SORT_DESCENDING); 18printf("SCANDIR_SORT_NONE: %d\n", SCANDIR_SORT_NONE); 19 20/* 21 * Pass different integers as $sorting_order argument to test how scandir() 22 * re-orders the array 23 */ 24 25echo "*** Testing scandir() : usage variations ***\n"; 26 27// include for create_files/delete_files functions 28include(dirname(__FILE__) . '/../file/file.inc'); 29 30// create directory and files 31$dir = dirname(__FILE__) . '/私はガラスを食べられますscandir_variation10'; 32mkdir($dir); 33@create_files($dir, 2, "numeric", 0755, 1, "w", "私はガラスを食べられますfile"); 34 35// Deterministic tests. 36var_dump(scandir($dir, SCANDIR_SORT_ASCENDING)); 37var_dump(scandir($dir, SCANDIR_SORT_DESCENDING)); 38 39// Non-deterministic tests. 40$files = scandir($dir, SCANDIR_SORT_NONE); 41var_dump(count($files)); 42var_dump(in_array('.', $files)); 43var_dump(in_array('..', $files)); 44var_dump(in_array('私はガラスを食べられますfile1.tmp', $files)); 45var_dump(in_array('私はガラスを食べられますfile2.tmp', $files)); 46 47delete_files($dir, 2, "私はガラスを食べられますfile"); 48?> 49===DONE=== 50--CLEAN-- 51<?php 52$dir = dirname(__FILE__) . '/私はガラスを食べられますscandir_variation10'; 53rmdir($dir); 54?> 55--EXPECTF-- 56SCANDIR_SORT_ASCENDING: 0 57SCANDIR_SORT_DESCENDING: 1 58SCANDIR_SORT_NONE: 2 59*** Testing scandir() : usage variations *** 60array(4) { 61 [0]=> 62 string(1) "." 63 [1]=> 64 string(2) ".." 65 [2]=> 66 string(45) "私はガラスを食べられますfile1.tmp" 67 [3]=> 68 string(45) "私はガラスを食べられますfile2.tmp" 69} 70array(4) { 71 [0]=> 72 string(45) "私はガラスを食べられますfile2.tmp" 73 [1]=> 74 string(45) "私はガラスを食べられますfile1.tmp" 75 [2]=> 76 string(2) ".." 77 [3]=> 78 string(1) "." 79} 80int(4) 81bool(true) 82bool(true) 83bool(true) 84bool(true) 85===DONE=== 86