1--TEST--
2Test round() function : usage variations - different data types as $precision argument
3--INI--
4precision=14
5--FILE--
6<?php
7/* Prototype  : float round  ( float $val  [, int $precision  ] )
8 * Description: Returns the rounded value of val  to specified precision (number of digits
9 * after the decimal point)
10 * Source code: ext/standard/math.c
11 */
12
13echo "*** Testing round() : usage variations ***\n";
14
15//get an unset variable
16$unset_var = 10;
17unset ($unset_var);
18
19// heredoc string
20$heredoc = <<<EOT
21abc
22xyz
23EOT;
24
25// get a class
26class classA
27{
28}
29
30// get a resource variable
31$fp = fopen(__FILE__, "r");
32
33$inputs = array(
34       // int data
35/*1*/  0,
36       1,
37       12345,
38       -2345,
39       2147483647,
40
41       // float data
42/*6*/  10.5,
43       -10.5,
44       12.3456789000e5,
45       12.3456789000E-5,
46       .5,
47
48       // null data
49/*11*/ NULL,
50       null,
51
52       // boolean data
53/*13*/ true,
54       false,
55       TRUE,
56       FALSE,
57
58       // empty data
59/*17*/ "",
60       '',
61       array(),
62
63       // string data
64/*20*/ "abcxyz",
65       'abcxyz',
66       $heredoc,
67
68       // object data
69/*23*/ new classA(),
70
71       // undefined data
72/*24*/ @$undefined_var,
73
74       // unset data
75/*25*/ @$unset_var,
76
77       // resource variable
78/*26*/ $fp
79);
80
81// loop through each element of $inputs to check the behaviour of round()
82$iterator = 1;
83foreach($inputs as $input) {
84	echo "\n-- Iteration $iterator --\n";
85	var_dump(round(123.4456789, $input));
86	$iterator++;
87};
88fclose($fp);
89?>
90===Done===
91--EXPECTF--
92*** Testing round() : usage variations ***
93
94-- Iteration 1 --
95float(123)
96
97-- Iteration 2 --
98float(123.4)
99
100-- Iteration 3 --
101float(123.4456789)
102
103-- Iteration 4 --
104float(0)
105
106-- Iteration 5 --
107float(123.4456789)
108
109-- Iteration 6 --
110float(123.4456789)
111
112-- Iteration 7 --
113float(0)
114
115-- Iteration 8 --
116float(123.4456789)
117
118-- Iteration 9 --
119float(123)
120
121-- Iteration 10 --
122float(123)
123
124-- Iteration 11 --
125float(123)
126
127-- Iteration 12 --
128float(123)
129
130-- Iteration 13 --
131float(123.4)
132
133-- Iteration 14 --
134float(123)
135
136-- Iteration 15 --
137float(123.4)
138
139-- Iteration 16 --
140float(123)
141
142-- Iteration 17 --
143
144Warning: round() expects parameter 2 to be integer, string given in %s on line %d
145NULL
146
147-- Iteration 18 --
148
149Warning: round() expects parameter 2 to be integer, string given in %s on line %d
150NULL
151
152-- Iteration 19 --
153
154Warning: round() expects parameter 2 to be integer, array given in %s on line %d
155NULL
156
157-- Iteration 20 --
158
159Warning: round() expects parameter 2 to be integer, string given in %s on line %d
160NULL
161
162-- Iteration 21 --
163
164Warning: round() expects parameter 2 to be integer, string given in %s on line %d
165NULL
166
167-- Iteration 22 --
168
169Warning: round() expects parameter 2 to be integer, string given in %s on line %d
170NULL
171
172-- Iteration 23 --
173
174Warning: round() expects parameter 2 to be integer, object given in %s on line %d
175NULL
176
177-- Iteration 24 --
178float(123)
179
180-- Iteration 25 --
181float(123)
182
183-- Iteration 26 --
184
185Warning: round() expects parameter 2 to be integer, resource given in %s on line %d
186NULL
187===Done===