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--EXPECTF-- 48Warning: A non-numeric value encountered in %s on line %d 49int(3) 50string(4) "1foo" 51bool(false) 52bool(true) 53int(-1) 54int(1) 55int(0) 56bool(false) 57bool(false) 58bool(true) 59bool(false) 60bool(true) 61string(3) "bar" 62string(3) "foo" 63string(3) "bar" 64int(1) 65int(0) 66string(3) "foo" 67array(6) { 68 [0]=> 69 bool(false) 70 ["foo"]=> 71 string(3) "foo" 72 [42]=> 73 int(42) 74 [3]=> 75 float(3.14) 76 [""]=> 77 NULL 78 [1]=> 79 bool(true) 80} 81string(3) "abc" 82