Constants

This lesson discusses all there is to know about constants, i.e., defining them, checking if they're defined and using them in PHP programs.

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:

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy