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