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--
61Notice: Undefined variable: undef in %s on line 5
62
63Attempt to access various kinds of class constants:
64
65Warning: Use of undefined constant UNDEFINED - assumed 'UNDEFINED' (this will throw an Error in a future version of PHP) in %s on line %d
66string(9) "UNDEFINED"
67int(1)
68float(1.5)
69int(1)
70float(1.5)
71int(-1)
72float(-1.5)
73int(15)
74string(%d) "%s"
75string(1) "C"
76string(1) "C"
77string(0) ""
78int(1234)
79int(456)
80NULL
81string(6) "hello1"
82string(6) "hello2"
83string(6) "hello2"
84string(6) "hello2"
85
86Expecting fatal error:
87
88Fatal error: Uncaught Error: Undefined class constant 'c19' in %s:53
89Stack trace:
90#0 {main}
91  thrown in %s on line 53
92