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
15echo "*** Testing file_get_contents() : variation ***\n";
16
17/* An array of filenames */
18$names_arr = array(
19  /* Invalid args */
20  "-1" => -1,
21  "TRUE" => TRUE,
22  "FALSE" => FALSE,
23  "NULL" => NULL,
24  "\"\"" => "",
25  "\" \"" => " ",
26  "\\0" => "\0",
27  "array()" => array(),
28
29  /* prefix with path separator of a non existing directory*/
30  "/no/such/file/dir" => "/no/such/file/dir",
31  "php/php"=> "php/php"
32
33);
34
35foreach($names_arr as $key =>$value) {
36    echo "\n-- Filename: $key --\n";
37    try {
38        var_dump(file_get_contents($value));
39    } catch (\TypeError|\ValueError $e) {
40        echo get_class($e) . ': ' . $e->getMessage(), "\n";
41    }
42}
43
44?>
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 --
59ValueError: Path cannot be empty
60
61-- Filename: NULL --
62ValueError: Path cannot be empty
63
64-- Filename: "" --
65ValueError: Path cannot be empty
66
67-- Filename: " " --
68
69Warning: file_get_contents( ): Failed to open stream: Permission denied in %s on line %d
70bool(false)
71
72-- Filename: \0 --
73ValueError: file_get_contents(): Argument #1 ($filename) must not contain any null bytes
74
75-- Filename: array() --
76TypeError: file_get_contents(): Argument #1 ($filename) must be of type string, array given
77
78-- Filename: /no/such/file/dir --
79
80Warning: file_get_contents(/no/such/file/dir): Failed to open stream: No such file or directory in %s on line %d
81bool(false)
82
83-- Filename: php/php --
84
85Warning: file_get_contents(php/php): Failed to open stream: No such file or directory in %s on line %d
86bool(false)
87