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