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