Abstract Constants

By WebSmithery

There’s a pretty common pattern to declare “abstract class constants” in PHP.

PHP lazy loading will prevent the error “Fatal error: Uncaught Error: Cannot declare self-referencing constant self::NAME” if the constant is overloaded.

This makes an effective ‘abstract constant’, that must be defined to be usable.

../_images/abstract_constant.png