1--TEST--
2Test fgetc() function : usage variations - closed handle
3--FILE--
4<?php
5/*
6 Prototype: string fgetc ( resource $handle );
7 Description: Gets character from file pointer
8*/
9
10/* try reading a char using fgetc() using invalid handles
11    - closed file handle
12    - unset file handle
13*/
14
15// include the header for common test function
16include ("file.inc");
17
18echo "*** Testing fgetc() : usage variations ***\n";
19
20echo "-- Testing fgetc() with closed handle --\n";
21// open the file for reading
22$file_handle = fopen(__FILE__, "r");
23// close the file
24fclose($file_handle);
25
26// read from closed file
27var_dump( fgetc($file_handle) );
28
29echo "-- Testing fgetc() with unset handle --\n";
30// open the file for reading
31$file_handle = fopen(__FILE__, "r");
32// unset the file handle
33unset($file_handle);
34
35//fgetc using unset handle
36var_dump( fgetc($file_handle) );
37
38echo "Done";
39?>
40--EXPECTF--
41*** Testing fgetc() : usage variations ***
42-- Testing fgetc() with closed handle --
43
44Warning: fgetc(): %d is not a valid stream resource in %s on line %d
45bool(false)
46-- Testing fgetc() with unset handle --
47
48Notice: Undefined variable: file_handle in %s on line %d
49
50Warning: fgetc() expects parameter 1 to be resource, null given in %s on line %d
51bool(false)
52Done
53