Constants
Explore how to define immutable constants in PHP using const and define, learn the conventions for naming them, and discover how to check for their existence. Understand reserved constant names and how to retrieve all user-defined and built-in constants for effective coding.
We'll cover the following...
We'll cover the following...
Defining Constants #
Constants, by definition, are variables that cannot be modified during the execution of the script. They are created using the const statement or the define function.
Convention: In PHP, the convention is to use uppercase letters for constant names, e.g.,
A_CONSTANT.
The following code snippet shows how constants are created:
If you have already defined one constant, you can define another one based on it:
...