<?php
// define class constant linking to a not defined constant
const CONST_FOO = FOO;
const CONST_BAR = BAR;
echo "Define the linked constant AFTER reading:\n";
CONST_FOO;
define('FOO', 'Value of FOO');
var_dump(CONST_FOO);
echo "Define the linked constant BEFORE reading:\n";
define('BAR', 'Value of BAR');
var_dump(CONST_BAR);
Fatal error: Uncaught Error: Undefined constant "FOO" in /in/TYWog:5
Stack trace:
#0 {main}
thrown in /in/TYWog on line 5
Process exited with code 255.
Warning: Use of undefined constant FOO - assumed 'FOO' (this will throw an Error in a future version of PHP) in /in/TYWog on line 5
Warning: Use of undefined constant BAR - assumed 'BAR' (this will throw an Error in a future version of PHP) in /in/TYWog on line 8
Define the linked constant AFTER reading:
string(3) "FOO"
Define the linked constant BEFORE reading:
string(3) "BAR"
Notice: Use of undefined constant FOO - assumed 'FOO' in /in/TYWog on line 5
Notice: Use of undefined constant BAR - assumed 'BAR' in /in/TYWog on line 8
Define the linked constant AFTER reading:
string(3) "FOO"
Define the linked constant BEFORE reading:
string(3) "BAR"