1--TEST-- 2Test is_file() function: usage variations - invalid filenames 3--CONFLICTS-- 4obscure_filename 5--FILE-- 6<?php 7/* Prototype: bool is_file ( string $filename ); 8 Description: Tells whether the filename is a regular file 9 Returns TRUE if the filename exists and is a regular file 10*/ 11 12/* Testing is_file() with invalid arguments -int, float, bool, NULL, resource */ 13 14function flatten($variable) { 15 \ob_start(); 16 \var_dump($variable); 17 $flattened = 18 \ob_get_contents(); 19 \ob_end_clean(); 20 return \trim($flattened); 21} 22 23foreach([ 24 /* Invalid filenames */ 25 -2.34555, 26 " ", 27 "", 28 true, 29 false, 30 null, 31 32 /* scalars */ 33 1234, 34 0, 35 36 /* resource */ 37 fopen(__FILE__, "r") 38] as $filename ) { 39 printf( 40 "%s: %d\n", 41 flatten($filename), @is_file($filename)); 42 clearstatcache(); 43} 44?> 45--EXPECTF-- 46float(-2.34555): 0 47string(1) " ": 0 48string(0) "": 0 49bool(true): 0 50bool(false): 0 51NULL: 0 52int(1234): 0 53int(0): 0 54resource(%d) of type (stream): 0 55