Can we set visibility of class constant?
For this example:
class MyClass {
const CONST_VALUE = 'A constant value';
}
Can we specify
public const CONST_VALUE = 'A constant value';
or
private const CONST_VALUE = 'A constant value';
or
protected const CONST_VALUE = 'A constant value';
Update: visibility modifiers for constants have been added in PHP 7.1 (released 1st of December 2016). See the RFC : Support Class Constant Visibility.
The syntax looks like this:
class ClassName {
private const PRIVATE_CONST = 0;
protected const PROTECTED_CONST = 0;
public const PUBLIC_CONST = 0;
}