1--TEST--
2Test utf8_decode() function : usage variations  - different types for data
3--FILE--
4<?php
5/* Prototype  : proto string utf8_decode(string data)
6 * Description: Converts a UTF-8 encoded string to ISO-8859-1
7 * Source code: ext/standard/string.c
8 * Alias to functions:
9 */
10
11echo "*** Testing utf8_decode() : usage variations ***\n";
12error_reporting(E_ALL & ~E_NOTICE);
13
14class aClass {
15   function __toString() {
16       return "Some Ascii Data";
17   }
18}
19
20// Initialise function arguments not being substituted (if any)
21
22//get an unset variable
23$unset_var = 10;
24unset ($unset_var);
25
26//array of values to iterate over
27$values = array(
28
29      // int data
30      0,
31      1,
32      12345,
33      -2345,
34
35      // float data
36      10.5,
37      -10.5,
38      10.1234567e10,
39      10.7654321E-10,
40      .5,
41
42      // array data
43      array(),
44      array(0),
45      array(1),
46      array(1, 2),
47      array('color' => 'red', 'item' => 'pen'),
48
49      // null data
50      NULL,
51      null,
52
53      // boolean data
54      true,
55      false,
56      TRUE,
57      FALSE,
58
59      // empty data
60      "",
61      '',
62
63      // object data
64      new aClass(),
65
66      // undefined data
67      $undefined_var,
68
69      // unset data
70      $unset_var,
71);
72
73// loop through each element of the array for data
74
75foreach($values as $value) {
76      echo @"\nArg value $value \n";
77      var_dump( utf8_decode($value) );
78};
79
80echo "Done";
81?>
82--EXPECTF--
83*** Testing utf8_decode() : usage variations ***
84
85Arg value 0
86string(1) "0"
87
88Arg value 1
89string(1) "1"
90
91Arg value 12345
92string(5) "12345"
93
94Arg value -2345
95string(5) "-2345"
96
97Arg value 10.5
98string(4) "10.5"
99
100Arg value -10.5
101string(5) "-10.5"
102
103Arg value 101234567000
104string(12) "101234567000"
105
106Arg value 1.07654321E-9
107string(13) "1.07654321E-9"
108
109Arg value 0.5
110string(3) "0.5"
111
112Arg value Array
113
114Warning: utf8_decode() expects parameter 1 to be string, array given in %s on line %d
115NULL
116
117Arg value Array
118
119Warning: utf8_decode() expects parameter 1 to be string, array given in %s on line %d
120NULL
121
122Arg value Array
123
124Warning: utf8_decode() expects parameter 1 to be string, array given in %s on line %d
125NULL
126
127Arg value Array
128
129Warning: utf8_decode() expects parameter 1 to be string, array given in %s on line %d
130NULL
131
132Arg value Array
133
134Warning: utf8_decode() expects parameter 1 to be string, array given in %s on line %d
135NULL
136
137Arg value
138string(0) ""
139
140Arg value
141string(0) ""
142
143Arg value 1
144string(1) "1"
145
146Arg value
147string(0) ""
148
149Arg value 1
150string(1) "1"
151
152Arg value
153string(0) ""
154
155Arg value
156string(0) ""
157
158Arg value
159string(0) ""
160
161Arg value Some Ascii Data
162string(15) "Some Ascii Data"
163
164Arg value
165string(0) ""
166
167Arg value
168string(0) ""
169Done
170