<?php
// define class constant linking to a not defined constant
interface Foo {
const FOO = FOO;
}
interface Bar {
const BAR = BAR;
}
echo "Define the linked constant AFTER reading:\n";
Foo::FOO;
define('FOO', 'Value of FOO');
var_dump(Foo::FOO);
echo "Define the linked constant BEFORE reading:\n";
define('BAR', 'Value of BAR');
var_dump(Bar::BAR);
Define the linked constant AFTER reading:
Fatal error: Uncaught Error: Undefined constant "FOO" in /in/NGfkv:13
Stack trace:
#0 {main}
thrown in /in/NGfkv on line 13
Process exited with code 255.
Define the linked constant AFTER reading:
Warning: Use of undefined constant FOO - assumed 'FOO' (this will throw an Error in a future version of PHP) in /in/NGfkv on line 13
string(3) "FOO"
Define the linked constant BEFORE reading:
string(12) "Value of BAR"
Define the linked constant AFTER reading:
Notice: Use of undefined constant FOO - assumed 'FOO' in /in/NGfkv on line 13
string(3) "FOO"
Define the linked constant BEFORE reading:
string(12) "Value of BAR"
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING in /in/NGfkv on line 4
Process exited with code 255.