1--TEST-- 2Test fflush() function: usage variations - file opened in read-only mode 3--FILE-- 4<?php 5 6/* test fflush() with handle to a file opened in read-only mode as resource */ 7 8$file_path = __DIR__; 9require $file_path.'/file.inc'; 10 11echo "*** Testing fflush(): with file handles of files opened in various read modes ***\n"; 12$file_modes = array("r", "rb", "rt"); 13 14$file_name = "$file_path/fflush_variation4.tmp"; 15 16$count = 1; 17 18foreach( $file_modes as $mode ) { 19 echo "-- Iteration $count with file opened in $mode mode --\n"; 20 21 // creating a file 22 $file_handle = fopen($file_name, "w"); 23 if($file_handle == false) 24 exit("Error:failed to open file $file_name"); 25 fclose($file_handle); 26 27 // opening the file in different read modes 28 $file_handle = fopen($file_name, $mode); 29 if($file_handle == false) 30 exit("Error:failed to open file $file_name"); 31 var_dump( fflush($file_handle) ); 32 fclose($file_handle); 33 34 unlink($file_name); 35 $count++; 36} 37 38echo "\n*** Done ***"; 39?> 40--EXPECT-- 41*** Testing fflush(): with file handles of files opened in various read modes *** 42-- Iteration 1 with file opened in r mode -- 43bool(true) 44-- Iteration 2 with file opened in rb mode -- 45bool(true) 46-- Iteration 3 with file opened in rt mode -- 47bool(true) 48 49*** Done *** 50