1--TEST--
2Test exif_tagname() function : usage variations  - different types for index argument
3--SKIPIF--
4<?php if (!extension_loaded('exif')) print 'skip exif extension not available';?>
5--FILE--
6<?php
7
8/* Prototype  : string exif_tagname ( string $index  )
9 * Description: Get the header name for an index
10 * Source code: ext/exif/exif.c
11*/
12
13echo "*** Testing exif_tagname() : different types for index argument ***\n";
14// initialize all required variables
15
16// get an unset variable
17$unset_var = 'string_val';
18unset($unset_var);
19
20// declaring a class
21class sample  {
22  public function __toString() {
23  return "obj'ct";
24  }
25}
26
27// Defining resource
28$file_handle = fopen(__FILE__, 'r');
29
30// array with different values
31$values =  array (
32
33  // integer values
34  0,
35  1,
36  12345,
37  -2345,
38
39  // float values
40  10.5,
41  -10.5,
42  10.1234567e10,
43  10.7654321E-10,
44  .5,
45
46  // array values
47  array(),
48  array(0),
49  array(1),
50  array(1, 2),
51  array('color' => 'red', 'item' => 'pen'),
52
53  // boolean values
54  true,
55  false,
56  TRUE,
57  FALSE,
58
59  // empty string
60  "",
61  '',
62
63  // undefined variable
64  $undefined_var,
65
66  // unset variable
67  $unset_var,
68
69  // objects
70  new sample(),
71
72  // resource
73  $file_handle,
74
75  NULL,
76  null
77);
78
79
80// loop through each element of the array and check the working of exif_tagname()
81// when $index argument is supplied with different values
82
83echo "\n--- Testing exif_tagname() by supplying different values for 'index' argument ---\n";
84$counter = 1;
85foreach($values as $index) {
86  echo "-- Iteration $counter --\n";
87  var_dump( exif_tagname($index) );
88  $counter ++;
89}
90
91// closing the file
92fclose($file_handle);
93
94echo "Done\n";
95?>
96
97?>
98===Done===
99--EXPECTF--
100*** Testing exif_tagname() : different types for index argument ***
101
102Notice: Undefined variable: undefined_var in %s on line %d
103
104Notice: Undefined variable: unset_var in %s on line %d
105
106--- Testing exif_tagname() by supplying different values for 'index' argument ---
107-- Iteration 1 --
108bool(false)
109-- Iteration 2 --
110bool(false)
111-- Iteration 3 --
112bool(false)
113-- Iteration 4 --
114bool(false)
115-- Iteration 5 --
116bool(false)
117-- Iteration 6 --
118bool(false)
119-- Iteration 7 --
120bool(false)
121-- Iteration 8 --
122bool(false)
123-- Iteration 9 --
124bool(false)
125-- Iteration 10 --
126
127Warning: exif_tagname() expects parameter 1 to be long, array given in %s on line %d
128NULL
129-- Iteration 11 --
130
131Warning: exif_tagname() expects parameter 1 to be long, array given in %s on line %d
132NULL
133-- Iteration 12 --
134
135Warning: exif_tagname() expects parameter 1 to be long, array given in %s on line %d
136NULL
137-- Iteration 13 --
138
139Warning: exif_tagname() expects parameter 1 to be long, array given in %s on line %d
140NULL
141-- Iteration 14 --
142
143Warning: exif_tagname() expects parameter 1 to be long, array given in %s on line %d
144NULL
145-- Iteration 15 --
146bool(false)
147-- Iteration 16 --
148bool(false)
149-- Iteration 17 --
150bool(false)
151-- Iteration 18 --
152bool(false)
153-- Iteration 19 --
154
155Warning: exif_tagname() expects parameter 1 to be long, string given in %s on line %d
156NULL
157-- Iteration 20 --
158
159Warning: exif_tagname() expects parameter 1 to be long, string given in %s on line %d
160NULL
161-- Iteration 21 --
162bool(false)
163-- Iteration 22 --
164bool(false)
165-- Iteration 23 --
166
167Warning: exif_tagname() expects parameter 1 to be long, object given in %s on line %d
168NULL
169-- Iteration 24 --
170
171Warning: exif_tagname() expects parameter 1 to be long, resource given in %s on line %d
172NULL
173-- Iteration 25 --
174bool(false)
175-- Iteration 26 --
176bool(false)
177Done
178
179?>
180===Done===
181
182