import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-file / 007_variation13.php
blobdaf20c3bd351611f3bf15bcc379405f57a9dadf7
1 <?php
2 /*
3 fopen() function:
4 Prototype: resource fopen(string $filename, string $mode
5 [, bool $use_include_path [, resource $context]] );
6 Description: Opens file or URL.
7 */
8 /*
9 fclose() function:
10 Prototype: bool fclose ( resource $handle );
11 Description: Closes an open file pointer
14 /* Test fopen() and fclose(): Opening the file in "at" mode,
15 checking for the file creation, write & read operations,
16 checking for the file pointer position,
17 and fclose function
19 $file_path = dirname(__FILE__);
20 require($file_path."/file.inc");
22 create_files($file_path, 1, "text_with_new_line", 0755, 20, "w", "007_variation", 13, "bytes");
23 $file = $file_path."/007_variation13.tmp";
24 $string = "abcdefghij\nmnopqrst\tuvwxyz\n0123456789";
26 echo "*** Test fopen() & fclose() functions: with 'at' mode ***\n";
27 $file_handle = fopen($file, "at"); //opening the file "at" mode
28 var_dump($file_handle); //Check for the content of handle
29 var_dump( get_resource_type($file_handle) ); //Check for the type of resource
30 var_dump( fwrite($file_handle, $string) ); //Check for write operation; passes; expected:size of the $string
31 rewind($file_handle);
32 var_dump( fread($file_handle, 100) ); //Check for read operation; fails; expected: empty string
33 var_dump( ftell($file_handle) ); //File pointer position after read operation, expected at the end of the file
34 var_dump( fclose($file_handle) ); //Check for close operation on the file handle
35 var_dump( get_resource_type($file_handle) ); //Check whether resource is lost after close operation
36 var_dump( filesize($file) ); //Check that data hasn't over written; Expected: Size of (initial data + newly added data)
38 unlink($file); //Deleting the file
39 fclose( fopen($file, "at") ); //Opening the non-existing file in "at" mode, which will be created
40 var_dump( file_exists($file) ); //Check for the existance of file
41 echo "*** Done ***\n"; <?php
42 unlink(dirname(__FILE__)."/007_variation13.tmp");