In PHP when you define a class level constant as in:
const MY_CONSTANT = 'hello constant';
Why can't you initialize this value with a function such as
const MY_FILEPATH = dirname(dirname(__FILE__)) . '/heres-my-file.php';
In PHP when you define a class level constant as in:
const MY_CONSTANT = 'hello constant';
Why can't you initialize this value with a function such as
const MY_FILEPATH = dirname(dirname(__FILE__)) . '/heres-my-file.php';
In short: The constants are replaced while parsing, but functions are executed while interpreting. The parser simply cannot know to what it should set the value of the content.
Constants are immutable. Therefore, if functions could change the value of a constant it wouldn't be a constant.