import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-file / fgetc_variation3.php
blob0c180cedebbd0a2498e1ad8b7aec56dd747ae7fb
1 <?php
2 /*
3 Prototype: string fgetc ( resource $handle );
4 Description: Gets character from file pointer
5 */
7 /* try fgetc on files which are opened in non readable modes
8 w, wb, wt,
9 a, ab, at,
10 x, xb, xt
12 // include the header for common test function
13 include ("file.inc");
15 echo "*** Testing fgetc() with file opened in write only mode ***\n";
17 $file_modes = array("w", "wb", "wt", "a", "ab", "at", "x", "xb", "xt");
18 $filename = dirname(__FILE__)."/fgetc_variation3.tmp";
19 foreach ($file_modes as $file_mode ) {
20 echo "-- File opened in mode : $file_mode --\n";
22 $file_handle = fopen($filename, $file_mode);
23 if(!$file_handle) {
24 echo "Error: failed to open file $filename!\n";
25 exit();
27 $data = "fgetc_variation test";
28 fwrite($file_handle, $data);
30 // rewind the file pointer to begining of the file
31 var_dump( rewind($file_handle) );
32 var_dump( ftell($file_handle) );
33 var_dump( feof($file_handle) );
35 // read from file
36 var_dump( fgetc($file_handle) ); // expected : no chars should be read
37 var_dump( ftell($file_handle) ); // ensure that file pointer position is not changed
38 var_dump( feof($file_handle) ); // check if end of file pointer is set
40 // close the file
41 fclose($file_handle);
43 // delete the file
44 unlink($filename);
47 echo "Done\n";