June 2017
Intermediate to advanced
536 pages
9h 49m
English
There are two types of constants in PHP, the constants and the class constants. The constants can be defined pretty much anywhere using the define construct, while the class constants are defined within the individual class or interface using the const keyword.
While we cannot say that one type of constant is more important than the other, PHP 5.6 made the difference between the two by allowing class constants with the array data type. Aside from that difference, both types of constants supported scalar values (integer, float, string, Boolean, or null).
The PHP 7 release addressed this inequality by adding the array data type to constants as well, making the following into valid expressions:
// The class constant - using ...