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