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