1--TEST--
2Test is_dir() function: usage variations - diff. path notations
3--FILE--
4<?php
5/* Prototype: bool is_dir ( string $dirname );
6   Description: Tells whether the dirname is a directory
7     Returns TRUE if the dirname exists and is a directory, FALSE  otherwise.
8*/
9
10/* Passing dir names with different notations, using slashes, wild-card chars */
11
12$file_path = dirname(__FILE__);
13
14echo "*** Testing is_dir() with different notations of dir names ***";
15$dir_name = "/is_dir_variation4";
16mkdir($file_path.$dir_name);
17
18$dirs_arr = array(
19  "is_dir_variation4",
20  "./is_dir_variation4",
21
22  /* Testing a file trailing slash */
23  "is_dir_variation4/",
24  "./is_dir_variation4/",
25
26  /* Testing file with double trailing slashes */
27  "is_dir_variation4//",
28  "./is_dir_variation4//",
29  ".//is_dir_variation4//",
30  "is_dir_vari*",
31
32  /* Testing Binary safe */
33  "./is_dir_variation4/".chr(0),
34  "is_dir_variation4\0"
35);
36
37$count = 1;
38/* loop through to test each element the above array */
39foreach($dirs_arr as $dir) {
40  echo "\n-- Iteration $count --\n";
41  var_dump( is_dir($file_path."/".$dir ) );
42  $count++;
43}
44
45echo "\n*** Done ***";
46?>
47--CLEAN--
48<?php
49$file_path = dirname(__FILE__);
50$dir_name = $file_path."/is_dir_variation4";
51rmdir($dir_name);
52?>
53--EXPECTF--
54*** Testing is_dir() with different notations of dir names ***
55-- Iteration 1 --
56bool(true)
57
58-- Iteration 2 --
59bool(true)
60
61-- Iteration 3 --
62bool(true)
63
64-- Iteration 4 --
65bool(true)
66
67-- Iteration 5 --
68bool(true)
69
70-- Iteration 6 --
71bool(true)
72
73-- Iteration 7 --
74bool(true)
75
76-- Iteration 8 --
77bool(false)
78
79-- Iteration 9 --
80bool(false)
81
82-- Iteration 10 --
83bool(false)
84
85*** Done ***
86