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