]> granicus.if.org Git - php/blob
d33b01dfb3
[php] /
1 --TEST--
2 Test is_file() function: usage variations - invalid filenames
3 --CONFLICTS--
4 obscure_filename
5 --FILE--
6 <?php
7 /* Prototype: bool is_file ( string $filename );
8    Description: Tells whether the filename is a regular file
9      Returns TRUE if the filename exists and is a regular file
10 */
11
12 /* Testing is_file() with invalid arguments -int, float, bool, NULL */
13
14 function flatten($variable) {
15     \ob_start();
16     \var_dump($variable);
17     $flattened =
18         \ob_get_contents();
19     \ob_end_clean();
20     return \trim($flattened);
21 }
22
23 foreach([
24   /* Invalid filenames */
25   -2.34555,
26   " ",
27   "",
28   true,
29   false,
30   null,
31
32   /* scalars */
33   1234,
34   0
35 ] as $filename ) {
36   printf(
37       "%s: %d\n",
38       flatten($filename), @is_file($filename));
39   clearstatcache();
40 }
41 ?>
42 --EXPECTF--
43 float(-2.34555): 0
44 string(1) " ": 0
45 string(0) "": 0
46 bool(true): 0
47 bool(false): 0
48 NULL: 0
49 int(1234): 0
50 int(0): 0