1--TEST-- 2Test getimagesize() function : usage variations - unexpected type for arg 1 3--FILE-- 4<?php 5/* Prototype : proto 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 * Alias to functions: 9 */ 10 11function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) { 12 echo "Error: $err_no - $err_msg, $filename($linenum)\n"; 13} 14set_error_handler('test_error_handler'); 15 16echo "*** Testing getimagesize() : usage variations ***\n"; 17 18// Initialise function arguments not being substituted (if any) 19$info = array(1, 2); 20 21//get an unset variable 22$unset_var = 10; 23unset ($unset_var); 24 25//array of values to iterate over 26$values = array( 27 28 // int data 29 "0" => 0, 30 "1" => 1, 31 "12345" => 12345, 32 "-2345" => -2345, 33 34 // float data 35 "10.5" => 10.5, 36 "-10.5" => -10.5, 37 "10.1234567e5" => 10.1234567e10, 38 "10.7654321e-5" => 10.7654321E-5, 39 .5, 40 41 // array data 42 "array()" => array(), 43 "array(0)" => array(0), 44 "array(1)" => array(1), 45 "array(1, 2)" => array(1, 2), 46 "array('color' => 'red', 'item' => 'pen')" => array('color' => 'red', 'item' => 'pen'), 47 48 // null data 49 "NULL" => NULL, 50 "null" => null, 51 52 // boolean data 53 "true" => true, 54 "false" => false, 55 "TRUE" => TRUE, 56 "FALSE" => FALSE, 57 58 // empty data 59 "\"\"" => "", 60 "''" => '', 61 62 // object data 63 "new stdclass()" => new stdclass(), 64 65 // undefined data 66 "undefined_var" => $undefined_var, 67 68 // unset data 69 "unset_var" => $unset_var, 70); 71 72// loop through each element of the array for imagefile 73 74foreach($values as $key => $value) { 75 echo "\n-- Arg value: $key --\n"; 76 var_dump( getimagesize($value, $info) ); 77}; 78 79?> 80===DONE=== 81--EXPECTF-- 82*** Testing getimagesize() : usage variations *** 83Error: 8 - Undefined variable: undefined_var, %s(%d) 84Error: 8 - Undefined variable: unset_var, %s(%d) 85 86-- Arg value: 0 -- 87Error: 2 - getimagesize(0): failed to open stream: No such file or directory, %s(%d) 88bool(false) 89 90-- Arg value: 1 -- 91Error: 2 - getimagesize(1): failed to open stream: No such file or directory, %s(%d) 92bool(false) 93 94-- Arg value: 12345 -- 95Error: 2 - getimagesize(12345): failed to open stream: No such file or directory, %s(%d) 96bool(false) 97 98-- Arg value: -2345 -- 99Error: 2 - getimagesize(-2345): failed to open stream: No such file or directory, %s(%d) 100bool(false) 101 102-- Arg value: 10.5 -- 103Error: 2 - getimagesize(10.5): failed to open stream: No such file or directory, %s(%d) 104bool(false) 105 106-- Arg value: -10.5 -- 107Error: 2 - getimagesize(-10.5): failed to open stream: No such file or directory, %s(%d) 108bool(false) 109 110-- Arg value: 10.1234567e5 -- 111Error: 2 - getimagesize(101234567000): failed to open stream: No such file or directory, %s(%d) 112bool(false) 113 114-- Arg value: 10.7654321e-5 -- 115Error: 2 - getimagesize(0.000107654321): failed to open stream: No such file or directory, %s(%d) 116bool(false) 117 118-- Arg value: 12346 -- 119Error: 2 - getimagesize(0.5): failed to open stream: No such file or directory, %s(%d) 120bool(false) 121 122-- Arg value: array() -- 123Error: 2 - getimagesize() expects parameter 1 to be string, array given, %s(%d) 124NULL 125 126-- Arg value: array(0) -- 127Error: 2 - getimagesize() expects parameter 1 to be string, array given, %s(%d) 128NULL 129 130-- Arg value: array(1) -- 131Error: 2 - getimagesize() expects parameter 1 to be string, array given, %s(%d) 132NULL 133 134-- Arg value: array(1, 2) -- 135Error: 2 - getimagesize() expects parameter 1 to be string, array given, %s(%d) 136NULL 137 138-- Arg value: array('color' => 'red', 'item' => 'pen') -- 139Error: 2 - getimagesize() expects parameter 1 to be string, array given, %s(%d) 140NULL 141 142-- Arg value: NULL -- 143Error: 2 - getimagesize(): Filename cannot be empty, %s(%d) 144bool(false) 145 146-- Arg value: null -- 147Error: 2 - getimagesize(): Filename cannot be empty, %s(%d) 148bool(false) 149 150-- Arg value: true -- 151Error: 2 - getimagesize(1): failed to open stream: No such file or directory, %s(%d) 152bool(false) 153 154-- Arg value: false -- 155Error: 2 - getimagesize(): Filename cannot be empty, %s(%d) 156bool(false) 157 158-- Arg value: TRUE -- 159Error: 2 - getimagesize(1): failed to open stream: No such file or directory, %s(%d) 160bool(false) 161 162-- Arg value: FALSE -- 163Error: 2 - getimagesize(): Filename cannot be empty, %s(%d) 164bool(false) 165 166-- Arg value: "" -- 167Error: 2 - getimagesize(): Filename cannot be empty, %s(%d) 168bool(false) 169 170-- Arg value: '' -- 171Error: 2 - getimagesize(): Filename cannot be empty, %s(%d) 172bool(false) 173 174-- Arg value: new stdclass() -- 175Error: 2 - getimagesize() expects parameter 1 to be string, object given, %s(%d) 176NULL 177 178-- Arg value: undefined_var -- 179Error: 2 - getimagesize(): Filename cannot be empty, %s(%d) 180bool(false) 181 182-- Arg value: unset_var -- 183Error: 2 - getimagesize(): Filename cannot be empty, %s(%d) 184bool(false) 185===DONE===