1--TEST--
2Test strval() function : usage variations  - Pass different data types as strval
3--FILE--
4<?php
5echo "*** Testing strval() : usage variations ***\n";
6
7//get an unset variable
8$unset_var = 10;
9unset ($unset_var);
10
11//getting the resource
12$file_handle = fopen(__FILE__, "r");
13
14class MyClass
15{
16  function __toString() {
17    return "MyClass";
18  }
19}
20
21//array of values to iterate over
22$values = array(
23          //Decimal values
24/*1*/	  0,
25          1,
26          12345,
27          -12345,
28
29          //Octal values
30/*5*/	  02,
31          010,
32          030071,
33          -030071,
34
35          //Hexadecimal values
36/*9*/	  0x0,
37          0x1,
38          0xABCD,
39          -0xABCD,
40
41          // float data
42/*13*/    100.5,
43          -100.5,
44          100.1234567e10,
45          100.7654321E-10,
46          .5,
47
48          // array data
49/*18*/    array(),
50          array('color' => 'red', 'item' => 'pen'),
51
52          // null data
53/*20*/    NULL,
54          null,
55
56          // boolean data
57/*22*/    true,
58          false,
59          TRUE,
60          FALSE,
61
62          // empty data
63/*26*/    "",
64          '',
65
66          // object data
67/*28*/    new MyClass(),
68
69          // resource
70/*29*/    $file_handle,
71
72          // undefined data
73/*30*/    @$undefined_var,
74
75          // unset data
76/*31*/    @$unset_var,
77);
78
79// loop through each element of the array for strval
80$iterator = 1;
81foreach($values as $value) {
82      echo "\n-- Iteration $iterator --\n";
83      var_dump( strval($value) );
84      $iterator++;
85};
86?>
87--EXPECTF--
88*** Testing strval() : usage variations ***
89
90-- Iteration 1 --
91string(1) "0"
92
93-- Iteration 2 --
94string(1) "1"
95
96-- Iteration 3 --
97string(5) "12345"
98
99-- Iteration 4 --
100string(6) "-12345"
101
102-- Iteration 5 --
103string(1) "2"
104
105-- Iteration 6 --
106string(1) "8"
107
108-- Iteration 7 --
109string(5) "12345"
110
111-- Iteration 8 --
112string(6) "-12345"
113
114-- Iteration 9 --
115string(1) "0"
116
117-- Iteration 10 --
118string(1) "1"
119
120-- Iteration 11 --
121string(5) "43981"
122
123-- Iteration 12 --
124string(6) "-43981"
125
126-- Iteration 13 --
127string(5) "100.5"
128
129-- Iteration 14 --
130string(6) "-100.5"
131
132-- Iteration 15 --
133string(13) "1001234567000"
134
135-- Iteration 16 --
136string(14) "1.007654321E-8"
137
138-- Iteration 17 --
139string(3) "0.5"
140
141-- Iteration 18 --
142
143Warning: Array to string conversion in %s on line %d
144string(5) "Array"
145
146-- Iteration 19 --
147
148Warning: Array to string conversion in %s on line %d
149string(5) "Array"
150
151-- Iteration 20 --
152string(0) ""
153
154-- Iteration 21 --
155string(0) ""
156
157-- Iteration 22 --
158string(1) "1"
159
160-- Iteration 23 --
161string(0) ""
162
163-- Iteration 24 --
164string(1) "1"
165
166-- Iteration 25 --
167string(0) ""
168
169-- Iteration 26 --
170string(0) ""
171
172-- Iteration 27 --
173string(0) ""
174
175-- Iteration 28 --
176string(7) "MyClass"
177
178-- Iteration 29 --
179string(%d) "Resource id #%d"
180
181-- Iteration 30 --
182string(0) ""
183
184-- Iteration 31 --
185string(0) ""
186