Examples of using class constant
class Goodbye {
  const LEAVING_MESSAGE = "Thank you for visiting US!\n";
  public function byebye() {
    echo self::LEAVING_MESSAGE;
  }
}

$goodbye = new Goodbye();

// Access const variable with getter method
$goodbye->byebye();

// Access const variable with class name
echo Goodbye::LEAVING_MESSAGE;

// Access const variable directly with object
echo $goodbye::LEAVING_MESSAGE;
About class constants:
Constants cannot be changed once it is declared
Class constants are case-sensitive
A class constant is declared inside a class with the const keyword
It is recommended to name the constants in all uppercase letters
by Valeri Tandilashvili
4 years ago
PHP
OOP
2
Pro tip: use ```triple backticks around text``` to write in code fences