1--TEST--
2Test is_file() function: usage variations - diff. path notations (Bug #42027)
3--FILE--
4<?php
5/* Passing file names with different notations, using slashes, wild-card chars */
6
7$file_path = __DIR__;
8
9echo "*** Testing is_file() with different notations of file names ***\n";
10$dir_name = $file_path."/is_file_variation4";
11mkdir($dir_name);
12$file_handle = fopen($dir_name."/is_file_variation4.tmp", "w");
13fclose($file_handle);
14
15$files_arr = array(
16  "/is_file_variation4/is_file_variation4.tmp",
17
18  /* Testing a file trailing slash */
19  "/is_file_variation4/is_file_variation4.tmp/",
20
21  /* Testing file with double slashes */
22  "/is_file_variation4//is_file_variation4.tmp",
23  "//is_file_variation4//is_file_variation4.tmp",
24  "/is_file_variation4/*.tmp",
25  "is_file_variation4/is_file*.tmp",
26
27  /* Testing Binary safe */
28  "/is_file_variation4/is_file_variation4.tmp".chr(0),
29  "/is_file_variation4/is_file_variation4.tmp\0"
30);
31
32$count = 1;
33/* loop through to test each element in the above array */
34foreach($files_arr as $file) {
35  echo "- Iteration $count -\n";
36  try {
37    var_dump( is_file( $file_path."/".$file ) );
38  } catch (Error $e) {
39    echo $e->getMessage(), "\n";
40  }
41  clearstatcache();
42  $count++;
43}
44
45echo "\n*** Done ***";
46?>
47--CLEAN--
48<?php
49$file_path = __DIR__;
50$dir_name = $file_path."/is_file_variation4";
51unlink($dir_name."/is_file_variation4.tmp");
52rmdir($dir_name);
53?>
54--EXPECT--
55*** Testing is_file() with different notations of file names ***
56- Iteration 1 -
57bool(true)
58- Iteration 2 -
59bool(false)
60- Iteration 3 -
61bool(true)
62- Iteration 4 -
63bool(true)
64- Iteration 5 -
65bool(false)
66- Iteration 6 -
67bool(false)
68- Iteration 7 -
69bool(false)
70- Iteration 8 -
71bool(false)
72
73*** Done ***
74