xref: /PHP-8.0/Zend/tests/021.phpt (revision 45f6b4ce)
1--TEST--
2?: operator
3--FILE--
4<?php
5var_dump(true ?: false);
6var_dump(false ?: true);
7var_dump(23 ?: 42);
8var_dump(0 ?: "bar");
9
10$a = 23;
11$b = 0;
12$c = "";
13$d = 23.5;
14
15var_dump($a ?: $b);
16var_dump($c ?: $d);
17
18var_dump(1 ?: print(2));
19
20$e = array();
21
22$e['e'] = 'e';
23$e['e'] = $e['e'] ?: 'e';
24print_r($e);
25?>
26--EXPECT--
27bool(true)
28bool(true)
29int(23)
30string(3) "bar"
31int(23)
32float(23.5)
33int(1)
34Array
35(
36    [e] => e
37)
38