August 2013
Intermediate to advanced
140 pages
1h 49m
English
CHAPTER 13
![]()
Constants
A constant is a variable with a value that cannot be changed in the script. Such a value must therefore be assigned at the same time as the constant is created. PHP provides two methods for creating constants: the const modifier and the define function.
Const
The const modifier is used to create class constants. Unlike regular properties, class constants do not have an access level specified, as they are always publicly visible. They also do not use the dollar sign parser token ($). The naming convention for constants is all-uppercase, with underscores separating each word.
class MyCircle{ const PI = 3.14;}
Constants must ...
Read now
Unlock full access