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