import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-file / fflush_variation1-win32.php
blob16a739266af98218d4407997c0973677bce5fb75
1 <?php
2 /* Prototype: bool fflush ( resource $handle );
3 Description: Flushes the output to a file
4 */
6 /* test fflush() with handle to the files opened in different modes */
8 $file_path = dirname(__FILE__);
9 require $file_path.'/file.inc';
11 echo "*** Testing fflush(): with various types of files ***\n";
12 $file_types = array("empty", "numeric", "text", "text_with_new_line", "alphanumeric");
13 $file_modes = array("w", "wb", "wt", "w+", "w+b", "w+t",
14 "a", "ab", "at", "a+","a+b", "a+t",
15 "x", "xb", "xt", "x+", "x+b", "x+t");
17 $file_name = "$file_path/fflush_variation1.tmp";
19 $count = 1;
21 foreach( $file_types as $type ) {
22 echo "-- Iteration $count with file containing $type Data--\n";
23 foreach( $file_modes as $mode ) {
24 echo "-- File opened in $mode mode --\n";
26 // creating the file except for x mode
27 if( substr($mode, 0, 1) != "x" ) {
28 $file_handle = fopen($file_name, "w");
29 if($file_handle == false)
30 exit("Error:failed to open file $file_name");
32 // filling the file some data if mode is append mode
33 if( substr($mode, 0, 1) == "a")
34 fill_file($file_handle, $type, 10);
35 fclose($file_handle);
38 // opening the file in different modes
39 $file_handle = fopen($file_name, $mode);
40 if($file_handle == false)
41 exit("Error:failed to open file $file_name");
43 // writing data to the file
44 var_dump( fill_file($file_handle, $type, 50) );
45 var_dump( fflush($file_handle) );
46 fclose($file_handle);
48 // reading the contents of the file after flushing
49 var_dump( readfile($file_name) );
50 unlink($file_name);
52 $count++;
55 echo "\n*** Done ***";