Lazy class constants in PHP

Lazy class constants in PHP

Lazy class constants in PHP: fast by design, sometimes surprising PHP has class constant, which are named literals. It also supports static constant expressions, where the value is not always a literal. Rather, it’s an expression that PHP doesn’t evaluate immediately. PHP evaluates it the first time the code needs it. This is the concept […]

Literal candidates for constants

Literal candidates for constants Literals are hard coded values in the source. Once they are written, they can’t be changed without altering the source code. This is always fine, initially, while building the first implementations. Yet, later, it may arise that such literal have to be managed from different points of the code. This is […]