1--TEST--
2Test file_get_contents() function : variation - obscure filenames
3--CREDITS--
4Dave Kelsey <d_kelsey@uk.ibm.com>
5--SKIPIF--
6<?php
7if(substr(PHP_OS, 0, 3) == "WIN")
8  die("skip Do not run on Windows");
9?>
10--FILE--
11<?php
12/* Prototype  : string file_get_contents(string filename [, bool use_include_path [, resource context [, long offset [, long maxlen]]]])
13 * Description: Read the entire file into a string
14 * Source code: ext/standard/file.c
15 * Alias to functions:
16 */
17
18echo "*** Testing file_get_contents() : variation ***\n";
19/* An array of filenames */
20$names_arr = array(
21  /* Invalid args */
22  -1,
23  TRUE,
24  FALSE,
25  NULL,
26  "",
27  " ",
28  "\0",
29  array(),
30
31  /* prefix with path separator of a non existing directory*/
32  "/no/such/file/dir",
33  "php/php"
34
35);
36
37for( $i=0; $i<count($names_arr); $i++ ) {
38  echo "-- Iteration $i --\n";
39  var_dump(file_get_contents($names_arr[$i]));
40}
41
42echo "\n*** Done ***\n";
43?>
44--EXPECTF--
45*** Testing file_get_contents() : variation ***
46-- Iteration 0 --
47
48Warning: file_get_contents(-1): failed to open stream: No such file or directory in %s on line %d
49bool(false)
50-- Iteration 1 --
51
52Warning: file_get_contents(1): failed to open stream: No such file or directory in %s on line %d
53bool(false)
54-- Iteration 2 --
55
56Warning: file_get_contents(): Filename cannot be empty in %s on line %d
57bool(false)
58-- Iteration 3 --
59
60Warning: file_get_contents(): Filename cannot be empty in %s on line %d
61bool(false)
62-- Iteration 4 --
63
64Warning: file_get_contents(): Filename cannot be empty in %s on line %d
65bool(false)
66-- Iteration 5 --
67
68Warning: file_get_contents( ): failed to open stream: No such file or directory in %s on line %d
69bool(false)
70-- Iteration 6 --
71bool(false)
72-- Iteration 7 --
73
74Warning: file_get_contents() expects parameter 1 to be string, array given in %s on line %d
75NULL
76-- Iteration 8 --
77
78Warning: file_get_contents(/no/such/file/dir): failed to open stream: %s in %s on line %d
79bool(false)
80-- Iteration 9 --
81
82Warning: file_get_contents(php/php): failed to open stream: No such file or directory in %s on line %d
83bool(false)
84
85*** Done ***
86