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