Am I correct in assuming that const properties are automatically public? Is there a way to make them private or protected?
Thanks in advance.
As of php7.1, you can define your class constants with access modifiers (public
, private
or protected
). Have a look at the following example:
';
echo self::anthony_stark, '
';
}
}
echo superheroes::kal_el, '
';
superheroes::show_remaining();
Credits: http://dwellupper.io/post/48/defining-class-constants-in-php