If the constant value is a variable, then this is not a constant, but a variable.
Since you are (correctly) trying to keep your applications and pushed aside from the global scope, you might be interested in the registry template. A registry is basically an illustrious array that stores everything you throw into it and is globally accessible throughout the application.
:
,
Runkit , , , , ( )
if ( file_exists('xyc') ) {
runkit_constant_redefine('Constants::USERNAME', 'xyz');
}
( ):
class Abc { const FOO = 1; const BAR = 2; }
class Xyz extends Abc { const FOO = 2; }
class_alias(file_exists('abc') ? 'Abc' : 'Xyz', 'Constants');
Abc Xyz USERNAME (FOO ). , , , Constants::USERNAME, . , . PHP5.3.
-5.3 Constants , . abc_constants.php xyz_constants.php, , USERNAME xyz, include .
USERNAME , , . filecheck eval , .
: , .