xref: /PHP-8.3/Zend/tests/compare_006_64bit.phpt (revision acbf7802)
1--TEST--
2comparing different variables (smaller or equal than)
3--SKIPIF--
4<?php if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); ?>
5--FILE--
6<?php
7
8class test {
9}
10
11$a = array(
12    array(1,2,3),
13    "",
14    1,
15    2.5,
16    0,
17    "string",
18    "123",
19    "2.5",
20    NULL,
21    true,
22    false,
23    new stdclass,
24    new stdclass,
25    new test,
26    array(),
27    -PHP_INT_MAX-1,
28    (string)(-PHP_INT_MAX-1),
29);
30
31$var_cnt = count($a);
32
33function my_dump($var) {
34    ob_start();
35    var_dump($var);
36    $buf = ob_get_clean();
37    echo str_replace("\n", "", $buf);
38}
39
40foreach($a as $var) {
41    for ($i = 0; $i < $var_cnt; $i++) {
42        my_dump($var);
43        echo ($var <= $a[$i]) ? " <= " : " > ";
44        my_dump($a[$i]);
45        echo "\n";
46    }
47}
48
49echo "Done\n";
50?>
51--EXPECTF--
52array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)} <= array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}
53array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)} > string(0) ""
54array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)} > int(1)
55array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)} > float(2.5)
56array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)} > int(0)
57array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)} > string(6) "string"
58array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)} > string(3) "123"
59array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)} > string(3) "2.5"
60array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)} > NULL
61array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)} <= bool(true)
62array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)} > bool(false)
63array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)} <= object(stdClass)#%d (0) {}
64array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)} <= object(stdClass)#%d (0) {}
65array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)} <= object(test)#%d (0) {}
66array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)} > array(0) {}
67array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)} > int(-9223372036854775808)
68array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)} > string(20) "-9223372036854775808"
69string(0) "" <= array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}
70string(0) "" <= string(0) ""
71string(0) "" <= int(1)
72string(0) "" <= float(2.5)
73string(0) "" <= int(0)
74string(0) "" <= string(6) "string"
75string(0) "" <= string(3) "123"
76string(0) "" <= string(3) "2.5"
77string(0) "" <= NULL
78string(0) "" <= bool(true)
79string(0) "" <= bool(false)
80string(0) "" <= object(stdClass)#%d (0) {}
81string(0) "" <= object(stdClass)#%d (0) {}
82string(0) "" <= object(test)#%d (0) {}
83string(0) "" <= array(0) {}
84string(0) "" <= int(-9223372036854775808)
85string(0) "" <= string(20) "-9223372036854775808"
86int(1) <= array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}
87int(1) > string(0) ""
88int(1) <= int(1)
89int(1) <= float(2.5)
90int(1) > int(0)
91int(1) <= string(6) "string"
92int(1) <= string(3) "123"
93int(1) <= string(3) "2.5"
94int(1) > NULL
95int(1) <= bool(true)
96int(1) > bool(false)
97int(1)
98Notice: Object of class stdClass could not be converted to int in %s on line %d
99 <= object(stdClass)#%d (0) {}
100int(1)
101Notice: Object of class stdClass could not be converted to int in %s on line %d
102 <= object(stdClass)#%d (0) {}
103int(1)
104Notice: Object of class test could not be converted to int in %s on line %d
105 <= object(test)#%d (0) {}
106int(1) <= array(0) {}
107int(1) > int(-9223372036854775808)
108int(1) > string(20) "-9223372036854775808"
109float(2.5) <= array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}
110float(2.5) > string(0) ""
111float(2.5) > int(1)
112float(2.5) <= float(2.5)
113float(2.5) > int(0)
114float(2.5) <= string(6) "string"
115float(2.5) <= string(3) "123"
116float(2.5) <= string(3) "2.5"
117float(2.5) > NULL
118float(2.5) <= bool(true)
119float(2.5) > bool(false)
120float(2.5)
121Notice: Object of class stdClass could not be converted to float in %s on line %d
122 > object(stdClass)#%d (0) {}
123float(2.5)
124Notice: Object of class stdClass could not be converted to float in %s on line %d
125 > object(stdClass)#%d (0) {}
126float(2.5)
127Notice: Object of class test could not be converted to float in %s on line %d
128 > object(test)#%d (0) {}
129float(2.5) <= array(0) {}
130float(2.5) > int(-9223372036854775808)
131float(2.5) > string(20) "-9223372036854775808"
132int(0) <= array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}
133int(0) > string(0) ""
134int(0) <= int(1)
135int(0) <= float(2.5)
136int(0) <= int(0)
137int(0) <= string(6) "string"
138int(0) <= string(3) "123"
139int(0) <= string(3) "2.5"
140int(0) <= NULL
141int(0) <= bool(true)
142int(0) <= bool(false)
143int(0)
144Notice: Object of class stdClass could not be converted to int in %s on line %d
145 <= object(stdClass)#%d (0) {}
146int(0)
147Notice: Object of class stdClass could not be converted to int in %s on line %d
148 <= object(stdClass)#%d (0) {}
149int(0)
150Notice: Object of class test could not be converted to int in %s on line %d
151 <= object(test)#%d (0) {}
152int(0) <= array(0) {}
153int(0) > int(-9223372036854775808)
154int(0) > string(20) "-9223372036854775808"
155string(6) "string" <= array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}
156string(6) "string" > string(0) ""
157string(6) "string" > int(1)
158string(6) "string" > float(2.5)
159string(6) "string" > int(0)
160string(6) "string" <= string(6) "string"
161string(6) "string" > string(3) "123"
162string(6) "string" > string(3) "2.5"
163string(6) "string" > NULL
164string(6) "string" <= bool(true)
165string(6) "string" > bool(false)
166string(6) "string" <= object(stdClass)#%d (0) {}
167string(6) "string" <= object(stdClass)#%d (0) {}
168string(6) "string" <= object(test)#%d (0) {}
169string(6) "string" <= array(0) {}
170string(6) "string" > int(-9223372036854775808)
171string(6) "string" > string(20) "-9223372036854775808"
172string(3) "123" <= array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}
173string(3) "123" > string(0) ""
174string(3) "123" > int(1)
175string(3) "123" > float(2.5)
176string(3) "123" > int(0)
177string(3) "123" <= string(6) "string"
178string(3) "123" <= string(3) "123"
179string(3) "123" > string(3) "2.5"
180string(3) "123" > NULL
181string(3) "123" <= bool(true)
182string(3) "123" > bool(false)
183string(3) "123" <= object(stdClass)#%d (0) {}
184string(3) "123" <= object(stdClass)#%d (0) {}
185string(3) "123" <= object(test)#%d (0) {}
186string(3) "123" <= array(0) {}
187string(3) "123" > int(-9223372036854775808)
188string(3) "123" > string(20) "-9223372036854775808"
189string(3) "2.5" <= array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}
190string(3) "2.5" > string(0) ""
191string(3) "2.5" > int(1)
192string(3) "2.5" <= float(2.5)
193string(3) "2.5" > int(0)
194string(3) "2.5" <= string(6) "string"
195string(3) "2.5" <= string(3) "123"
196string(3) "2.5" <= string(3) "2.5"
197string(3) "2.5" > NULL
198string(3) "2.5" <= bool(true)
199string(3) "2.5" > bool(false)
200string(3) "2.5" <= object(stdClass)#%d (0) {}
201string(3) "2.5" <= object(stdClass)#%d (0) {}
202string(3) "2.5" <= object(test)#%d (0) {}
203string(3) "2.5" <= array(0) {}
204string(3) "2.5" > int(-9223372036854775808)
205string(3) "2.5" > string(20) "-9223372036854775808"
206NULL <= array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}
207NULL <= string(0) ""
208NULL <= int(1)
209NULL <= float(2.5)
210NULL <= int(0)
211NULL <= string(6) "string"
212NULL <= string(3) "123"
213NULL <= string(3) "2.5"
214NULL <= NULL
215NULL <= bool(true)
216NULL <= bool(false)
217NULL <= object(stdClass)#%d (0) {}
218NULL <= object(stdClass)#%d (0) {}
219NULL <= object(test)#%d (0) {}
220NULL <= array(0) {}
221NULL <= int(-9223372036854775808)
222NULL <= string(20) "-9223372036854775808"
223bool(true) <= array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}
224bool(true) > string(0) ""
225bool(true) <= int(1)
226bool(true) <= float(2.5)
227bool(true) > int(0)
228bool(true) <= string(6) "string"
229bool(true) <= string(3) "123"
230bool(true) <= string(3) "2.5"
231bool(true) > NULL
232bool(true) <= bool(true)
233bool(true) > bool(false)
234bool(true) <= object(stdClass)#%d (0) {}
235bool(true) <= object(stdClass)#%d (0) {}
236bool(true) <= object(test)#%d (0) {}
237bool(true) > array(0) {}
238bool(true) <= int(-9223372036854775808)
239bool(true) <= string(20) "-9223372036854775808"
240bool(false) <= array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}
241bool(false) <= string(0) ""
242bool(false) <= int(1)
243bool(false) <= float(2.5)
244bool(false) <= int(0)
245bool(false) <= string(6) "string"
246bool(false) <= string(3) "123"
247bool(false) <= string(3) "2.5"
248bool(false) <= NULL
249bool(false) <= bool(true)
250bool(false) <= bool(false)
251bool(false) <= object(stdClass)#%d (0) {}
252bool(false) <= object(stdClass)#%d (0) {}
253bool(false) <= object(test)#%d (0) {}
254bool(false) <= array(0) {}
255bool(false) <= int(-9223372036854775808)
256bool(false) <= string(20) "-9223372036854775808"
257object(stdClass)#%d (0) {} > array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}
258object(stdClass)#%d (0) {} > string(0) ""
259object(stdClass)#%d (0) {}
260Notice: Object of class stdClass could not be converted to int in %s on line %d
261 <= int(1)
262object(stdClass)#%d (0) {}
263Notice: Object of class stdClass could not be converted to float in %s on line %d
264 <= float(2.5)
265object(stdClass)#%d (0) {}
266Notice: Object of class stdClass could not be converted to int in %s on line %d
267 > int(0)
268object(stdClass)#%d (0) {} > string(6) "string"
269object(stdClass)#%d (0) {} > string(3) "123"
270object(stdClass)#%d (0) {} > string(3) "2.5"
271object(stdClass)#%d (0) {} > NULL
272object(stdClass)#%d (0) {} <= bool(true)
273object(stdClass)#%d (0) {} > bool(false)
274object(stdClass)#%d (0) {} <= object(stdClass)#%d (0) {}
275object(stdClass)#%d (0) {} <= object(stdClass)#%d (0) {}
276object(stdClass)#%d (0) {} > object(test)#%d (0) {}
277object(stdClass)#%d (0) {} > array(0) {}
278object(stdClass)#%d (0) {}
279Notice: Object of class stdClass could not be converted to int in %s on line %d
280 > int(-9223372036854775808)
281object(stdClass)#%d (0) {} > string(20) "-9223372036854775808"
282object(stdClass)#%d (0) {} > array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}
283object(stdClass)#%d (0) {} > string(0) ""
284object(stdClass)#%d (0) {}
285Notice: Object of class stdClass could not be converted to int in %s on line %d
286 <= int(1)
287object(stdClass)#%d (0) {}
288Notice: Object of class stdClass could not be converted to float in %s on line %d
289 <= float(2.5)
290object(stdClass)#%d (0) {}
291Notice: Object of class stdClass could not be converted to int in %s on line %d
292 > int(0)
293object(stdClass)#%d (0) {} > string(6) "string"
294object(stdClass)#%d (0) {} > string(3) "123"
295object(stdClass)#%d (0) {} > string(3) "2.5"
296object(stdClass)#%d (0) {} > NULL
297object(stdClass)#%d (0) {} <= bool(true)
298object(stdClass)#%d (0) {} > bool(false)
299object(stdClass)#%d (0) {} <= object(stdClass)#%d (0) {}
300object(stdClass)#%d (0) {} <= object(stdClass)#%d (0) {}
301object(stdClass)#%d (0) {} > object(test)#%d (0) {}
302object(stdClass)#%d (0) {} > array(0) {}
303object(stdClass)#%d (0) {}
304Notice: Object of class stdClass could not be converted to int in %s on line %d
305 > int(-9223372036854775808)
306object(stdClass)#%d (0) {} > string(20) "-9223372036854775808"
307object(test)#%d (0) {} > array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}
308object(test)#%d (0) {} > string(0) ""
309object(test)#%d (0) {}
310Notice: Object of class test could not be converted to int in %s on line %d
311 <= int(1)
312object(test)#%d (0) {}
313Notice: Object of class test could not be converted to float in %s on line %d
314 <= float(2.5)
315object(test)#%d (0) {}
316Notice: Object of class test could not be converted to int in %s on line %d
317 > int(0)
318object(test)#%d (0) {} > string(6) "string"
319object(test)#%d (0) {} > string(3) "123"
320object(test)#%d (0) {} > string(3) "2.5"
321object(test)#%d (0) {} > NULL
322object(test)#%d (0) {} <= bool(true)
323object(test)#%d (0) {} > bool(false)
324object(test)#%d (0) {} > object(stdClass)#%d (0) {}
325object(test)#%d (0) {} > object(stdClass)#%d (0) {}
326object(test)#%d (0) {} <= object(test)#%d (0) {}
327object(test)#%d (0) {} > array(0) {}
328object(test)#%d (0) {}
329Notice: Object of class test could not be converted to int in %s on line %d
330 > int(-9223372036854775808)
331object(test)#%d (0) {} > string(20) "-9223372036854775808"
332array(0) {} <= array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}
333array(0) {} > string(0) ""
334array(0) {} > int(1)
335array(0) {} > float(2.5)
336array(0) {} > int(0)
337array(0) {} > string(6) "string"
338array(0) {} > string(3) "123"
339array(0) {} > string(3) "2.5"
340array(0) {} <= NULL
341array(0) {} <= bool(true)
342array(0) {} <= bool(false)
343array(0) {} <= object(stdClass)#%d (0) {}
344array(0) {} <= object(stdClass)#%d (0) {}
345array(0) {} <= object(test)#%d (0) {}
346array(0) {} <= array(0) {}
347array(0) {} > int(-9223372036854775808)
348array(0) {} > string(20) "-9223372036854775808"
349int(-9223372036854775808) <= array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}
350int(-9223372036854775808) > string(0) ""
351int(-9223372036854775808) <= int(1)
352int(-9223372036854775808) <= float(2.5)
353int(-9223372036854775808) <= int(0)
354int(-9223372036854775808) <= string(6) "string"
355int(-9223372036854775808) <= string(3) "123"
356int(-9223372036854775808) <= string(3) "2.5"
357int(-9223372036854775808) > NULL
358int(-9223372036854775808) <= bool(true)
359int(-9223372036854775808) > bool(false)
360int(-9223372036854775808)
361Notice: Object of class stdClass could not be converted to int in %s on line %d
362 <= object(stdClass)#%d (0) {}
363int(-9223372036854775808)
364Notice: Object of class stdClass could not be converted to int in %s on line %d
365 <= object(stdClass)#%d (0) {}
366int(-9223372036854775808)
367Notice: Object of class test could not be converted to int in %s on line %d
368 <= object(test)#%d (0) {}
369int(-9223372036854775808) <= array(0) {}
370int(-9223372036854775808) <= int(-9223372036854775808)
371int(-9223372036854775808) <= string(20) "-9223372036854775808"
372string(20) "-9223372036854775808" <= array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}
373string(20) "-9223372036854775808" > string(0) ""
374string(20) "-9223372036854775808" <= int(1)
375string(20) "-9223372036854775808" <= float(2.5)
376string(20) "-9223372036854775808" <= int(0)
377string(20) "-9223372036854775808" <= string(6) "string"
378string(20) "-9223372036854775808" <= string(3) "123"
379string(20) "-9223372036854775808" <= string(3) "2.5"
380string(20) "-9223372036854775808" > NULL
381string(20) "-9223372036854775808" <= bool(true)
382string(20) "-9223372036854775808" > bool(false)
383string(20) "-9223372036854775808" <= object(stdClass)#%d (0) {}
384string(20) "-9223372036854775808" <= object(stdClass)#%d (0) {}
385string(20) "-9223372036854775808" <= object(test)#%d (0) {}
386string(20) "-9223372036854775808" <= array(0) {}
387string(20) "-9223372036854775808" <= int(-9223372036854775808)
388string(20) "-9223372036854775808" <= string(20) "-9223372036854775808"
389Done
390