Cast In Const

../_images/cast_in_const.png

TIL that constant values accepts casting since PHP 8.5. It is possible to cast a value to another type when defining the global or class constant.

This might be most useful when a constant must be available in several flavor, rather than with literal values.

The only cast that is not supported is (object).

See Also

PHP Error Messages

PHP Features