PHP Basic Tutorial
MySQL Connection
PHP Advanced
PHP OOP
Class constants in PHP are fixed values that cannot be changed once they are defined.
Class constants are case-sensitive. However, it is recommended to name the constants in all uppercase letters.
const inside a class.$ symbol.ClassName::CONSTANT_NAME.class ClassName {
const CONSTANT_NAME = value;
}
Try it yourself
Or, we can access a constant from inside the class by using the self keyword followed by the scope resolution operator (::) followed by the constant name, like here:
Try it yourself