1--TEST--
2Test readfile() function : variation - various invalid paths
3--CREDITS--
4Dave Kelsey <d_kelsey@uk.ibm.com>
5--SKIPIF--
6<?php
7if(substr(PHP_OS, 0, 3) != "WIN")
8  die("skip run only on Windows");
9?>
10--CONFLICTS--
11obscure_filename
12--FILE--
13<?php
14echo "*** Testing readfile() : variation ***\n";
15
16/* An array of files */
17$names_arr = array(
18  /* Invalid args */
19  "-1" => -1,
20  "TRUE" => TRUE,
21  "FALSE" => FALSE,
22  "\"\"" => "",
23  "\" \"" => " ",
24  "\\0" => "\0",
25  "array()" => array(),
26
27  /* prefix with path separator of a non existing directory*/
28  "/no/such/file/dir" => "/no/such/file/dir",
29  "php/php"=> "php/php"
30
31);
32
33foreach($names_arr as $key => $value) {
34    echo "\n-- Filename: $key --\n";
35    try {
36        readfile($value);
37    } catch (\TypeError|\ValueError $e) {
38        echo get_class($e) . ': ' . $e->getMessage(), "\n";
39    }
40}
41?>
42--EXPECTF--
43*** Testing readfile() : variation ***
44
45-- Filename: -1 --
46
47Warning: readfile(-1): Failed to open stream: No such file or directory in %s on line %d
48
49-- Filename: TRUE --
50
51Warning: readfile(1): Failed to open stream: No such file or directory in %s on line %d
52
53-- Filename: FALSE --
54ValueError: Path must not be empty
55
56-- Filename: "" --
57ValueError: Path must not be empty
58
59-- Filename: " " --
60
61Warning: readfile( ): Failed to open stream: Permission denied in %s on line %d
62
63-- Filename: \0 --
64ValueError: readfile(): Argument #1 ($filename) must not contain any null bytes
65
66-- Filename: array() --
67TypeError: readfile(): Argument #1 ($filename) must be of type string, array given
68
69-- Filename: /no/such/file/dir --
70
71Warning: readfile(/no/such/file/dir): Failed to open stream: No such file or directory in %s on line %d
72
73-- Filename: php/php --
74
75Warning: readfile(php/php): Failed to open stream: No such file or directory in %s on line %d
76