1--TEST-- 2Test is_file() function: usage variations - invalid filenames 3--FILE-- 4<?php 5/* Prototype: bool is_file ( string $filename ); 6 Description: Tells whether the filename is a regular file 7 Returns TRUE if the filename exists and is a regular file 8*/ 9 10/* Testing is_file() with invalid arguments -int, float, bool, NULL, resource */ 11 12$file_path = dirname(__FILE__); 13$file_handle = fopen($file_path."/is_file_variation3.tmp", "w"); 14 15echo "*** Testing Invalid file types ***\n"; 16$filenames = array( 17 /* Invalid filenames */ 18 -2.34555, 19 " ", 20 "", 21 TRUE, 22 FALSE, 23 NULL, 24 $file_handle, 25 26 /* scalars */ 27 1234, 28 0 29); 30 31/* loop through to test each element the above array */ 32foreach( $filenames as $filename ) { 33 var_dump( is_file($filename) ); 34 clearstatcache(); 35} 36fclose($file_handle); 37 38echo "\n*** Done ***"; 39?> 40--CLEAN-- 41<?php 42$file_path = dirname(__FILE__); 43unlink($file_path."/is_file_variation3.tmp"); 44?> 45--EXPECTF-- 46*** Testing Invalid file types *** 47bool(false) 48bool(false) 49bool(false) 50bool(false) 51bool(false) 52bool(false) 53 54Warning: is_file() expects parameter 1 to be string, resource given in %s on line %d 55NULL 56bool(false) 57bool(false) 58 59*** Done *** 60 61