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