Are there any best practices for defining and using constants in PHP classes?

When defining and using constants in PHP classes, it is a best practice to use all uppercase letters and underscores to separate words in the constant name. This convention helps differentiate constants from regular class properties. Additionally, constants should be declared as public static within the class to ensure they are easily accessible without needing an instance of the class.

class MyClass {
    public const MAX_ATTEMPTS = 3;
    
    public function doSomething() {
        for ($i = 0; $i < self::MAX_ATTEMPTS; $i++) {
            // do something
        }
    }
}