summaryrefslogtreecommitdiff
path: root/ext/standard/tests/file/readfile_error.phpt
blob: 6ae9f9a4dee123257fd60d29b1c5bd0d10c9ed53 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
--TEST--
Test readfile() function: error conditions
--FILE--
<?php
$context = stream_context_create();

echo "*** Test readfile(): error conditions ***\n";

echo "\n-- Testing readfile() with invalid arguments --\n";
// invalid arguments
var_dump( readfile(NULL) );  // NULL as $filename
var_dump( readfile('') );  // empty string as $filename
var_dump( readfile(false) );  // boolean false as $filename

echo "\n-- Testing readfile() with non-existent file --\n";
$non_existent_file = __DIR__."/non_existent_file.tmp";
var_dump( readfile($non_existent_file) );

echo "Done\n";
?>
--EXPECTF--
*** Test readfile(): error conditions ***

-- Testing readfile() with invalid arguments --

Warning: readfile(): Filename cannot be empty in %s on line %d
bool(false)

Warning: readfile(): Filename cannot be empty in %s on line %d
bool(false)

Warning: readfile(): Filename cannot be empty in %s on line %d
bool(false)

-- Testing readfile() with non-existent file --

Warning: readfile(%s/non_existent_file.tmp): Failed to open stream: %s in %s on line %d
bool(false)
Done