scandir_variation8.phpt 2.6 KB

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