import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-file / fgetc_variation1.php
blob0570a7918753b58cbb4467cc5457fa3aa1d6a577
1 <?php
2 /*
3 Prototype: string fgetc ( resource $handle );
4 Description: Gets character from file pointer
5 */
6 // include the header for common test function
7 include ("file.inc");
9 echo "*** Testing fgetc() : usage variations ***\n";
10 echo "-- Testing fgetc() with file whose file pointer is pointing to EOF --\n";
11 // create a file
12 create_files(dirname(__FILE__), 1, "text_with_new_line", 0755, 1, "w", "fgetc_variation");
14 $filename = dirname(__FILE__)."/fgetc_variation1.tmp";
16 // loop to check the file opened in different read modes
17 $file_modes = array("r", "rb", "rt", "r+", "r+b", "r+t");
18 $loop_counter =0;
19 for(; $loop_counter < count($file_modes); $loop_counter++) {
20 // print the hearder
21 echo "-- File opened in mode : $file_modes[$loop_counter] --\n";
22 // open the file
23 $file_handle = fopen ($filename, $file_modes[$loop_counter]);
24 if (!$file_handle) {
25 echo "Error: failed to open file $filename! \n";
26 exit();
29 // seek to end of the file and try fgetc()
30 var_dump( fseek($file_handle, 0, SEEK_END) ); // set file pointer to eof
31 var_dump( feof($file_handle) ); // expected false
32 var_dump( ftell($file_handle) ); // ensure that file pointer is at eof
33 var_dump( fgetc($file_handle) ); // try n read a char, none expected
34 var_dump( feof($file_handle) ); // ensure thta file pointer is at eof
35 var_dump( ftell($file_handle) ); // file pointer position
37 // close the file handle
38 fclose($file_handle);
40 echo "Done\n";
41 ?><?php
42 unlink( dirname(__FILE__)."/fgetc_variation1.tmp");