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