1--TEST-- 2Dynamic Constant Expressions 3--FILE-- 4<?php 5 6const C_0 = 0; 7const C_1 = 1; 8const C_foo = "foo"; 9const C_arr = [0 => 0, "foo" => "foo"]; 10 11const T_1 = C_1 | 2; 12const T_2 = C_1 . "foo"; 13const T_3 = C_1 > 1; 14const T_4 = C_1 >= 1; 15const T_5 = -C_1; 16const T_6 = +C_1; 17const T_7 = +C_foo; 18const T_8 = !C_1; 19const T_9 = C_0 || 0; 20const T_10 = C_1 || 0; 21const T_11 = C_0 && 1; 22const T_12 = C_1 && 1; 23const T_13 = C_0 ? "foo" : "bar"; 24const T_14 = C_1 ? "foo" : "bar"; 25const T_15 = C_0 ?: "bar"; 26const T_16 = C_1 ?: "bar"; 27const T_17 = C_arr[0]; 28const T_18 = C_arr["foo"]; 29const T_19 = [ 30 C_0, 31 "foo" => "foo", 32 42 => 42, 33 3.14 => 3.14, 34 null => null, 35 false => false, 36 true => true, 37]; 38eval("const T_20x = 'a';"); 39const T_20 = null ?: (T_20x . 'bc'); 40 41var_dump( 42 T_1, T_2, T_3, T_4, T_5, T_6, T_7, T_8, T_9, T_10, 43 T_11, T_12, T_13, T_14, T_15, T_16, T_17, T_18, T_19, T_20 44); 45 46?> 47--EXPECT-- 48int(3) 49string(4) "1foo" 50bool(false) 51bool(true) 52int(-1) 53int(1) 54int(0) 55bool(false) 56bool(false) 57bool(true) 58bool(false) 59bool(true) 60string(3) "bar" 61string(3) "foo" 62string(3) "bar" 63int(1) 64int(0) 65string(3) "foo" 66array(6) { 67 [0]=> 68 bool(false) 69 ["foo"]=> 70 string(3) "foo" 71 [42]=> 72 int(42) 73 [3]=> 74 float(3.14) 75 [""]=> 76 NULL 77 [1]=> 78 bool(true) 79} 80string(3) "abc" 81