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 Only 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
20/* An array of filenames */
21$names_arr = array(
22  /* Invalid args */
23  "-1" => -1,
24  "TRUE" => TRUE,
25  "FALSE" => FALSE,
26  "NULL" => NULL,
27  "\"\"" => "",
28  "\" \"" => " ",
29  "\\0" => "\0",
30  "array()" => array(),
31
32  /* prefix with path separator of a non existing directory*/
33  "/no/such/file/dir" => "/no/such/file/dir",
34  "php/php"=> "php/php"
35
36);
37
38foreach($names_arr as $key =>$value) {
39  echo "\n-- Filename: $key --\n";
40  var_dump(file_get_contents($value));
41}
42
43?>
44===Done===
45--EXPECTF--
46*** Testing file_get_contents() : variation ***
47
48-- Filename: -1 --
49
50Warning: file_get_contents(-1): failed to open stream: No such file or directory in %s on line %d
51bool(false)
52
53-- Filename: TRUE --
54
55Warning: file_get_contents(1): failed to open stream: No such file or directory in %s on line %d
56bool(false)
57
58-- Filename: FALSE --
59
60Warning: file_get_contents(): Filename cannot be empty in %s on line %d
61bool(false)
62
63-- Filename: NULL --
64
65Warning: file_get_contents(): Filename cannot be empty in %s on line %d
66bool(false)
67
68-- Filename: "" --
69
70Warning: file_get_contents(): Filename cannot be empty in %s on line %d
71bool(false)
72
73-- Filename: " " --
74
75Warning: file_get_contents( ): failed to open stream: Permission denied in %s on line %d
76bool(false)
77
78-- Filename: \0 --
79bool(false)
80
81-- Filename: array() --
82
83Warning: file_get_contents() expects parameter 1 to be string, array given in %s on line %d
84NULL
85
86-- Filename: /no/such/file/dir --
87
88Warning: file_get_contents(/no/such/file/dir): failed to open stream: No such file or directory in %s on line %d
89bool(false)
90
91-- Filename: php/php --
92
93Warning: file_get_contents(php/php): failed to open stream: No such file or directory in %s on line %d
94bool(false)
95===Done===