1--TEST-- 2Class constant declarations 3--FILE-- 4<?php 5 define('DEFINED', 1234); 6 $def = 456; 7 define('DEFINED_TO_VAR', $def); 8 define('DEFINED_TO_UNDEF_VAR', $undef); 9 10 class C 11 { 12 const c0 = UNDEFINED; 13 14 const c1 = 1, c2 = 1.5; 15 const c3 = + 1, c4 = + 1.5; 16 const c5 = -1, c6 = -1.5; 17 18 const c7 = __LINE__; 19 const c8 = __FILE__; 20 const c9 = __CLASS__; 21 const c10 = __METHOD__; 22 const c11 = __FUNCTION__; 23 24 const c12 = DEFINED; 25 const c13 = DEFINED_TO_VAR; 26 const c14 = DEFINED_TO_UNDEF_VAR; 27 28 const c15 = "hello1"; 29 const c16 = 'hello2'; 30 const c17 = C::c16; 31 const c18 = self::c17; 32 } 33 34 echo "\nAttempt to access various kinds of class constants:\n"; 35 var_dump(C::c0); 36 var_dump(C::c1); 37 var_dump(C::c2); 38 var_dump(C::c3); 39 var_dump(C::c4); 40 var_dump(C::c5); 41 var_dump(C::c6); 42 var_dump(C::c7); 43 var_dump(C::c8); 44 var_dump(C::c9); 45 var_dump(C::c10); 46 var_dump(C::c11); 47 var_dump(C::c12); 48 var_dump(C::c13); 49 var_dump(C::c14); 50 var_dump(C::c15); 51 var_dump(C::c16); 52 var_dump(C::c17); 53 var_dump(C::c18); 54 55 echo "\nExpecting fatal error:\n"; 56 var_dump(C::c19); 57 58 echo "\nYou should not see this."; 59?> 60--EXPECTF-- 61 62Notice: Undefined variable: undef in %s on line 5 63 64Attempt to access various kinds of class constants: 65 66Notice: Use of undefined constant UNDEFINED - assumed 'UNDEFINED' in %s on line %d 67string(9) "UNDEFINED" 68int(1) 69float(1.5) 70int(1) 71float(1.5) 72int(-1) 73float(-1.5) 74int(15) 75string(%d) "%s" 76string(1) "C" 77string(1) "C" 78string(0) "" 79int(1234) 80int(456) 81NULL 82string(6) "hello1" 83string(6) "hello2" 84string(6) "hello2" 85string(6) "hello2" 86 87Expecting fatal error: 88 89Fatal error: Undefined class constant 'c19' in %s on line 53 90