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