You can also create a class constants in php classes. These are constants designed to be used by classes, not objects.
<?php
class Math
{
const pi = 3.14159;
}
?>
Now you can refer to the constant pi in code inside the Math class as self::pi. You can use the constant with self:: rather than $this because for class constants, there’s no object involved.
Trending Tutorials