Annotation of embedaddon/php/ext/standard/tests/file/fgets_variation2.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test fgets() function : usage variations - closed handle
3: --FILE--
4: <?php
5: /*
6: Prototype: string fgets ( resource $handle [, int $length] );
7: Description: Gets a line from file pointer
8: */
9:
10: /* try reading a line using fgets() using invalid handles
11: - closed file handle
12: - unset file handle
13: */
14:
15: // include the header for common test function
16: include ("file.inc");
17:
18: echo "*** Testing fgets() : usage variations ***\n";
19:
20: echo "-- Testing fgets() with closed handle --\n";
21: // open the file for reading
22: $file_handle = fopen(__FILE__, "r");
23: // close the file
24: fclose($file_handle);
25:
26: // read from closed file
27: var_dump( fgets($file_handle) ); // default length
28: var_dump( fgets($file_handle, 10) ); // with specific length
29:
30: echo "-- Testing fgets() with unset handle --\n";
31: // open the file for reading
32: $file_handle = fopen(__FILE__, "r");
33: // unset the file handle
34: unset($file_handle);
35:
36: //fgets using unset handle
37: var_dump( fgets($file_handle) ); // default length
38: var_dump( fgets($file_handle, 10) ); // with specific length
39:
40: echo "Done";
41: ?>
42: --EXPECTF--
43: *** Testing fgets() : usage variations ***
44: -- Testing fgets() with closed handle --
45:
46: Warning: fgets(): %d is not a valid stream resource in %s on line %d
47: bool(false)
48:
49: Warning: fgets(): %d is not a valid stream resource in %s on line %d
50: bool(false)
51: -- Testing fgets() with unset handle --
52:
53: Notice: Undefined variable: file_handle in %s on line %d
54:
55: Warning: fgets() expects parameter 1 to be resource, null given in %s on line %d
56: bool(false)
57:
58: Notice: Undefined variable: file_handle in %s on line %d
59:
60: Warning: fgets() expects parameter 1 to be resource, null given in %s on line %d
61: bool(false)
62: Done
63:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>