xref: /PHP-8.0/Zend/tests/compare_002_64bit.phpt (revision f8d79582)
1--TEST--
2comparing different variables for identity
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) !== object(stdClass)#%d (0) {}
98int(1) !== object(stdClass)#%d (0) {}
99int(1) !== object(test)#%d (0) {}
100int(1) !== array(0) {}
101int(1) !== int(-9223372036854775808)
102int(1) !== string(20) "-9223372036854775808"
103float(2.5) !== array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}
104float(2.5) !== string(0) ""
105float(2.5) !== int(1)
106float(2.5) === float(2.5)
107float(2.5) !== int(0)
108float(2.5) !== string(6) "string"
109float(2.5) !== string(3) "123"
110float(2.5) !== string(3) "2.5"
111float(2.5) !== NULL
112float(2.5) !== bool(true)
113float(2.5) !== bool(false)
114float(2.5) !== object(stdClass)#%d (0) {}
115float(2.5) !== object(stdClass)#%d (0) {}
116float(2.5) !== object(test)#%d (0) {}
117float(2.5) !== array(0) {}
118float(2.5) !== int(-9223372036854775808)
119float(2.5) !== string(20) "-9223372036854775808"
120int(0) !== array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}
121int(0) !== string(0) ""
122int(0) !== int(1)
123int(0) !== float(2.5)
124int(0) === int(0)
125int(0) !== string(6) "string"
126int(0) !== string(3) "123"
127int(0) !== string(3) "2.5"
128int(0) !== NULL
129int(0) !== bool(true)
130int(0) !== bool(false)
131int(0) !== object(stdClass)#%d (0) {}
132int(0) !== object(stdClass)#%d (0) {}
133int(0) !== object(test)#%d (0) {}
134int(0) !== array(0) {}
135int(0) !== int(-9223372036854775808)
136int(0) !== string(20) "-9223372036854775808"
137string(6) "string" !== array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}
138string(6) "string" !== string(0) ""
139string(6) "string" !== int(1)
140string(6) "string" !== float(2.5)
141string(6) "string" !== int(0)
142string(6) "string" === string(6) "string"
143string(6) "string" !== string(3) "123"
144string(6) "string" !== string(3) "2.5"
145string(6) "string" !== NULL
146string(6) "string" !== bool(true)
147string(6) "string" !== bool(false)
148string(6) "string" !== object(stdClass)#%d (0) {}
149string(6) "string" !== object(stdClass)#%d (0) {}
150string(6) "string" !== object(test)#%d (0) {}
151string(6) "string" !== array(0) {}
152string(6) "string" !== int(-9223372036854775808)
153string(6) "string" !== string(20) "-9223372036854775808"
154string(3) "123" !== array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}
155string(3) "123" !== string(0) ""
156string(3) "123" !== int(1)
157string(3) "123" !== float(2.5)
158string(3) "123" !== int(0)
159string(3) "123" !== string(6) "string"
160string(3) "123" === string(3) "123"
161string(3) "123" !== string(3) "2.5"
162string(3) "123" !== NULL
163string(3) "123" !== bool(true)
164string(3) "123" !== bool(false)
165string(3) "123" !== object(stdClass)#%d (0) {}
166string(3) "123" !== object(stdClass)#%d (0) {}
167string(3) "123" !== object(test)#%d (0) {}
168string(3) "123" !== array(0) {}
169string(3) "123" !== int(-9223372036854775808)
170string(3) "123" !== string(20) "-9223372036854775808"
171string(3) "2.5" !== array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}
172string(3) "2.5" !== string(0) ""
173string(3) "2.5" !== int(1)
174string(3) "2.5" !== float(2.5)
175string(3) "2.5" !== int(0)
176string(3) "2.5" !== string(6) "string"
177string(3) "2.5" !== string(3) "123"
178string(3) "2.5" === string(3) "2.5"
179string(3) "2.5" !== NULL
180string(3) "2.5" !== bool(true)
181string(3) "2.5" !== bool(false)
182string(3) "2.5" !== object(stdClass)#%d (0) {}
183string(3) "2.5" !== object(stdClass)#%d (0) {}
184string(3) "2.5" !== object(test)#%d (0) {}
185string(3) "2.5" !== array(0) {}
186string(3) "2.5" !== int(-9223372036854775808)
187string(3) "2.5" !== string(20) "-9223372036854775808"
188NULL !== array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}
189NULL !== string(0) ""
190NULL !== int(1)
191NULL !== float(2.5)
192NULL !== int(0)
193NULL !== string(6) "string"
194NULL !== string(3) "123"
195NULL !== string(3) "2.5"
196NULL === NULL
197NULL !== bool(true)
198NULL !== bool(false)
199NULL !== object(stdClass)#%d (0) {}
200NULL !== object(stdClass)#%d (0) {}
201NULL !== object(test)#%d (0) {}
202NULL !== array(0) {}
203NULL !== int(-9223372036854775808)
204NULL !== string(20) "-9223372036854775808"
205bool(true) !== array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}
206bool(true) !== string(0) ""
207bool(true) !== int(1)
208bool(true) !== float(2.5)
209bool(true) !== int(0)
210bool(true) !== string(6) "string"
211bool(true) !== string(3) "123"
212bool(true) !== string(3) "2.5"
213bool(true) !== NULL
214bool(true) === bool(true)
215bool(true) !== bool(false)
216bool(true) !== object(stdClass)#%d (0) {}
217bool(true) !== object(stdClass)#%d (0) {}
218bool(true) !== object(test)#%d (0) {}
219bool(true) !== array(0) {}
220bool(true) !== int(-9223372036854775808)
221bool(true) !== string(20) "-9223372036854775808"
222bool(false) !== array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}
223bool(false) !== string(0) ""
224bool(false) !== int(1)
225bool(false) !== float(2.5)
226bool(false) !== int(0)
227bool(false) !== string(6) "string"
228bool(false) !== string(3) "123"
229bool(false) !== string(3) "2.5"
230bool(false) !== NULL
231bool(false) !== bool(true)
232bool(false) === bool(false)
233bool(false) !== object(stdClass)#%d (0) {}
234bool(false) !== object(stdClass)#%d (0) {}
235bool(false) !== object(test)#%d (0) {}
236bool(false) !== array(0) {}
237bool(false) !== int(-9223372036854775808)
238bool(false) !== string(20) "-9223372036854775808"
239object(stdClass)#%d (0) {} !== array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}
240object(stdClass)#%d (0) {} !== string(0) ""
241object(stdClass)#%d (0) {} !== int(1)
242object(stdClass)#%d (0) {} !== float(2.5)
243object(stdClass)#%d (0) {} !== int(0)
244object(stdClass)#%d (0) {} !== string(6) "string"
245object(stdClass)#%d (0) {} !== string(3) "123"
246object(stdClass)#%d (0) {} !== string(3) "2.5"
247object(stdClass)#%d (0) {} !== NULL
248object(stdClass)#%d (0) {} !== bool(true)
249object(stdClass)#%d (0) {} !== bool(false)
250object(stdClass)#%d (0) {} === object(stdClass)#%d (0) {}
251object(stdClass)#%d (0) {} !== object(stdClass)#%d (0) {}
252object(stdClass)#%d (0) {} !== object(test)#%d (0) {}
253object(stdClass)#%d (0) {} !== array(0) {}
254object(stdClass)#%d (0) {} !== int(-9223372036854775808)
255object(stdClass)#%d (0) {} !== string(20) "-9223372036854775808"
256object(stdClass)#%d (0) {} !== array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}
257object(stdClass)#%d (0) {} !== string(0) ""
258object(stdClass)#%d (0) {} !== int(1)
259object(stdClass)#%d (0) {} !== float(2.5)
260object(stdClass)#%d (0) {} !== int(0)
261object(stdClass)#%d (0) {} !== string(6) "string"
262object(stdClass)#%d (0) {} !== string(3) "123"
263object(stdClass)#%d (0) {} !== string(3) "2.5"
264object(stdClass)#%d (0) {} !== NULL
265object(stdClass)#%d (0) {} !== bool(true)
266object(stdClass)#%d (0) {} !== bool(false)
267object(stdClass)#%d (0) {} !== object(stdClass)#%d (0) {}
268object(stdClass)#%d (0) {} === object(stdClass)#%d (0) {}
269object(stdClass)#%d (0) {} !== object(test)#%d (0) {}
270object(stdClass)#%d (0) {} !== array(0) {}
271object(stdClass)#%d (0) {} !== int(-9223372036854775808)
272object(stdClass)#%d (0) {} !== string(20) "-9223372036854775808"
273object(test)#%d (0) {} !== array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}
274object(test)#%d (0) {} !== string(0) ""
275object(test)#%d (0) {} !== int(1)
276object(test)#%d (0) {} !== float(2.5)
277object(test)#%d (0) {} !== int(0)
278object(test)#%d (0) {} !== string(6) "string"
279object(test)#%d (0) {} !== string(3) "123"
280object(test)#%d (0) {} !== string(3) "2.5"
281object(test)#%d (0) {} !== NULL
282object(test)#%d (0) {} !== bool(true)
283object(test)#%d (0) {} !== bool(false)
284object(test)#%d (0) {} !== object(stdClass)#%d (0) {}
285object(test)#%d (0) {} !== object(stdClass)#%d (0) {}
286object(test)#%d (0) {} === object(test)#%d (0) {}
287object(test)#%d (0) {} !== array(0) {}
288object(test)#%d (0) {} !== int(-9223372036854775808)
289object(test)#%d (0) {} !== string(20) "-9223372036854775808"
290array(0) {} !== array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}
291array(0) {} !== string(0) ""
292array(0) {} !== int(1)
293array(0) {} !== float(2.5)
294array(0) {} !== int(0)
295array(0) {} !== string(6) "string"
296array(0) {} !== string(3) "123"
297array(0) {} !== string(3) "2.5"
298array(0) {} !== NULL
299array(0) {} !== bool(true)
300array(0) {} !== bool(false)
301array(0) {} !== object(stdClass)#%d (0) {}
302array(0) {} !== object(stdClass)#%d (0) {}
303array(0) {} !== object(test)#%d (0) {}
304array(0) {} === array(0) {}
305array(0) {} !== int(-9223372036854775808)
306array(0) {} !== string(20) "-9223372036854775808"
307int(-9223372036854775808) !== array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}
308int(-9223372036854775808) !== string(0) ""
309int(-9223372036854775808) !== int(1)
310int(-9223372036854775808) !== float(2.5)
311int(-9223372036854775808) !== int(0)
312int(-9223372036854775808) !== string(6) "string"
313int(-9223372036854775808) !== string(3) "123"
314int(-9223372036854775808) !== string(3) "2.5"
315int(-9223372036854775808) !== NULL
316int(-9223372036854775808) !== bool(true)
317int(-9223372036854775808) !== bool(false)
318int(-9223372036854775808) !== object(stdClass)#%d (0) {}
319int(-9223372036854775808) !== object(stdClass)#%d (0) {}
320int(-9223372036854775808) !== object(test)#%d (0) {}
321int(-9223372036854775808) !== array(0) {}
322int(-9223372036854775808) === int(-9223372036854775808)
323int(-9223372036854775808) !== string(20) "-9223372036854775808"
324string(20) "-9223372036854775808" !== array(3) {  [0]=>  int(1)  [1]=>  int(2)  [2]=>  int(3)}
325string(20) "-9223372036854775808" !== string(0) ""
326string(20) "-9223372036854775808" !== int(1)
327string(20) "-9223372036854775808" !== float(2.5)
328string(20) "-9223372036854775808" !== int(0)
329string(20) "-9223372036854775808" !== string(6) "string"
330string(20) "-9223372036854775808" !== string(3) "123"
331string(20) "-9223372036854775808" !== string(3) "2.5"
332string(20) "-9223372036854775808" !== NULL
333string(20) "-9223372036854775808" !== bool(true)
334string(20) "-9223372036854775808" !== bool(false)
335string(20) "-9223372036854775808" !== object(stdClass)#%d (0) {}
336string(20) "-9223372036854775808" !== object(stdClass)#%d (0) {}
337string(20) "-9223372036854775808" !== object(test)#%d (0) {}
338string(20) "-9223372036854775808" !== array(0) {}
339string(20) "-9223372036854775808" !== int(-9223372036854775808)
340string(20) "-9223372036854775808" === string(20) "-9223372036854775808"
341Done
342