1--TEST--
2Test image_type_to_mime_type() function : usage variations  - Pass different data types as imagetype
3--FILE--
4<?php
5/* Prototype  : string image_type_to_mime_type(int imagetype)
6 * Description: Get Mime-Type for image-type returned by getimagesize, exif_read_data, exif_thumbnail, exif_imagetype
7 * Source code: ext/standard/image.c
8 */
9
10echo "*** Testing image_type_to_mime_type() : usage variations ***\n";
11
12error_reporting(E_ALL ^ E_NOTICE);
13
14//get an unset variable
15$unset_var = 10;
16unset ($unset_var);
17
18class MyClass
19{
20  function __toString() {
21    return "MyClass";
22  }
23}
24
25//array of values to iterate over
26$values = array(
27
28      // float data
29      100.5,
30      -100.5,
31      100.1234567e10,
32      100.7654321E-10,
33      .5,
34
35      // array data
36      array(),
37      array('color' => 'red', 'item' => 'pen'),
38
39      // null data
40      NULL,
41      null,
42
43      // boolean data
44      true,
45      false,
46      TRUE,
47      FALSE,
48
49      // empty data
50      "",
51      '',
52
53      // string data
54      "string",
55      'string',
56
57      // object data
58      new MyClass(),
59
60      // undefined data
61      @$undefined_var,
62
63      // unset data
64      @$unset_var,
65);
66
67// loop through each element of the array for imagetype
68$iterator = 1;
69foreach($values as $value) {
70      echo "\n-- Iteration $iterator --\n";
71      var_dump( image_type_to_mime_type($value) );
72      $iterator++;
73};
74?>
75===DONE===
76--EXPECTF--
77*** Testing image_type_to_mime_type() : usage variations ***
78
79-- Iteration 1 --
80string(24) "application/octet-stream"
81
82-- Iteration 2 --
83string(24) "application/octet-stream"
84
85-- Iteration 3 --
86string(24) "application/octet-stream"
87
88-- Iteration 4 --
89string(24) "application/octet-stream"
90
91-- Iteration 5 --
92string(24) "application/octet-stream"
93
94-- Iteration 6 --
95
96Warning: image_type_to_mime_type() expects parameter 1 to be long, array given in %s on line %d
97NULL
98
99-- Iteration 7 --
100
101Warning: image_type_to_mime_type() expects parameter 1 to be long, array given in %s on line %d
102NULL
103
104-- Iteration 8 --
105string(24) "application/octet-stream"
106
107-- Iteration 9 --
108string(24) "application/octet-stream"
109
110-- Iteration 10 --
111string(9) "image/gif"
112
113-- Iteration 11 --
114string(24) "application/octet-stream"
115
116-- Iteration 12 --
117string(9) "image/gif"
118
119-- Iteration 13 --
120string(24) "application/octet-stream"
121
122-- Iteration 14 --
123
124Warning: image_type_to_mime_type() expects parameter 1 to be long, string given in %s on line %d
125NULL
126
127-- Iteration 15 --
128
129Warning: image_type_to_mime_type() expects parameter 1 to be long, string given in %s on line %d
130NULL
131
132-- Iteration 16 --
133
134Warning: image_type_to_mime_type() expects parameter 1 to be long, string given in %s on line %d
135NULL
136
137-- Iteration 17 --
138
139Warning: image_type_to_mime_type() expects parameter 1 to be long, string given in %s on line %d
140NULL
141
142-- Iteration 18 --
143
144Warning: image_type_to_mime_type() expects parameter 1 to be long, object given in %s on line %d
145NULL
146
147-- Iteration 19 --
148string(24) "application/octet-stream"
149
150-- Iteration 20 --
151string(24) "application/octet-stream"
152===DONE===