Constants

suggest change

Syntax

Remarks

Constants are used to store the values that are not supposed to be changed later. They also are often used to store the configuration parameters especially those which define the environment (dev/production).

Constants are typed, but not every value was always allowed. Arrays are allowed in const from PHP 5.6 and in define() from PHP 7.0. Since PHP 8.1, a const expression may include new. On current PHP, define() also accepts objects and resources; that will not work on PHP 7. Class constants still have to be constant expressions, so you cannot assign an arbitrary runtime value with const.

Some constant names are reserved by PHP. These include true, false, null as well as many module-specific constants.

Constants are usually named using uppercase letters.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents