1--TEST-- 2Test getimagesize() function : variation - Passing non image files 3--FILE-- 4<?php 5$file_types_array = array ( 6 //File containing text string 7 "File with text data" => "test.txt", 8 9 //File containing forcibly corrupted bmp image 10 "File with corrupted BMP data" => "200x100_unknown.unknown", 11 12 //File which doesn't exist 13 "Non-existent file" => "nofile.ext", 14 15 //File having no data 16 "Empty File" => "blank_file.bmp" 17); 18 19echo "*** Testing getimagesize() : variation ***\n"; 20 21//loop through each element of the array for filename 22foreach($file_types_array as $key => $filename) { 23 echo "\n-- $key ($filename) --\n"; 24 var_dump( getimagesize(__DIR__."/$filename" ) ); 25 var_dump( getimagesize(__DIR__."/$filename", $info) ); 26 var_dump( $info ); 27}; 28?> 29--EXPECTF-- 30*** Testing getimagesize() : variation *** 31 32-- File with text data (test.txt) -- 33bool(false) 34bool(false) 35array(0) { 36} 37 38-- File with corrupted BMP data (200x100_unknown.unknown) -- 39bool(false) 40bool(false) 41array(0) { 42} 43 44-- Non-existent file (nofile.ext) -- 45 46Warning: getimagesize(%snofile.ext): Failed to open stream: No such file or directory in %s on line %d 47bool(false) 48 49Warning: getimagesize(%snofile.ext): Failed to open stream: No such file or directory in %s on line %d 50bool(false) 51array(0) { 52} 53 54-- Empty File (blank_file.bmp) -- 55 56Notice: getimagesize(): Error reading from %s! in %s on line %d 57bool(false) 58 59Notice: getimagesize(): Error reading from %s! in %s on line %d 60bool(false) 61array(0) { 62} 63