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