A Dynamic Constant
<?php
function foo() {}
const FOO = strtolower(...);
const FOO2 = FOO(...);
const FOO3 = (FOO)(...);
Generally speaking, parenthesis are allowed in static constant expression: this is the case in constant values. Yet, here, the PHP engine returns Cannot use dynamic function name in constant expression.
The problem comes from the last constant definition: it builds a closure with the ellipsis as the arguments. But the name of the function is the constant FOO. As a constant, it should be valid.
Now, that constant is actually not known at compilation time. The PHP engine needs to start and execute some code to have access to the constant value. Hence, it is dynamic.
A variable constant, if you want.
See Also
- Where is the dynamic constant? [Try me]
PHP Error Messages
PHP Features
Last updated: 09 November 2026