1--TEST-- 2Test is_file() function: usage variations - diff. files 3--FILE-- 4<?php 5/* Testing is_file() with file containing data, truncating its size 6 and the file created by touch() */ 7 8$file_path = __DIR__; 9 10echo "-- Testing is_file() with file containing data --\n"; 11$filename = $file_path."/is_file_variation1.tmp"; 12$file_handle = fopen($filename, "w" ); 13fwrite( $file_handle, "Hello, world....." ); // expected true 14fclose($file_handle); 15var_dump( is_file($filename) ); 16clearstatcache(); 17 18echo "\n-- Testing is_file() after truncating filesize to zero bytes --\n"; 19$file_handle = fopen( $file_path."/is_file_variation1.tmp", "r"); 20ftruncate($file_handle, 0); 21fclose($file_handle); 22var_dump( is_file($file_path."/is_file_variation1.tmp") ); // expected true 23clearstatcache(); 24unlink($file_path."/is_file_variation1.tmp"); 25 26echo "\n-- Testing is_file() with an empty file --\n"; 27/* created by fopen() */ 28fclose( fopen($file_path."/is_file_variation1.tmp", "w") ); 29var_dump( is_file($file_path."/is_file_variation1.tmp") ); //expected true 30clearstatcache(); 31unlink($file_path."/is_file_variation1.tmp"); 32 33/* created by touch() */ 34touch($file_path."/is_file_variation1.tmp"); 35var_dump( is_file($file_path."/is_file_variation1.tmp") ); // expected true 36clearstatcache(); 37unlink($file_path."/is_file_variation1.tmp"); 38 39echo "\n*** Done ***"; 40?> 41--EXPECT-- 42-- Testing is_file() with file containing data -- 43bool(true) 44 45-- Testing is_file() after truncating filesize to zero bytes -- 46bool(true) 47 48-- Testing is_file() with an empty file -- 49bool(true) 50bool(true) 51 52*** Done *** 53