1--TEST--
2Test fopen and fclose() functions - usage variations - "rt" mode
3--FILE--
4<?php
5
6/* Test fopen() and fclose(): Opening the file in "rt" mode,
7   checking for the file creation, write & read operations,
8   checking for the file pointer position,
9   and fclose function
10*/
11$file_path = __DIR__;
12require($file_path."/file.inc");
13
14create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 9, "bytes");
15$file = $file_path."/007_variation9.tmp";
16$string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789";
17
18echo "*** Test fopen() & fclose() functions:  with 'rt' mode ***\n";
19$file_handle = fopen($file, "rt");  //opening the file in "rt" mode
20var_dump($file_handle);  //Check for the content of handle
21var_dump( get_resource_type($file_handle) );  //Check for the type of resource
22var_dump( ftell($file_handle) );  //Initial position of file pointer
23var_dump( fread($file_handle, 100) );  //Check for read operation
24var_dump( fwrite($file_handle, $string) );  //Check for write operation; fails
25var_dump( fclose($file_handle) );  //Check for close operation on the file handle
26var_dump( get_resource_type($file_handle) );  //Check whether resource is lost after close operation
27echo "*** Done ***\n";
28--CLEAN--
29<?php
30unlink(__DIR__."/007_variation9.tmp");
31?>
32--EXPECTF--
33*** Test fopen() & fclose() functions:  with 'rt' mode ***
34resource(%d) of type (stream)
35string(6) "stream"
36int(0)
37string(20) "line
38line of text
39li"
40
41Notice: fwrite(): Write of 37 bytes failed with errno=9 Bad file descriptor in %s on line %d
42bool(false)
43bool(true)
44string(7) "Unknown"
45*** Done ***
46