Static Members and Class Constants
static belongs to the class and const holds fixed values. Access with ::.
Example
class M {
const PI = 3.14;
public static $n = 0;
static function inc() { return ++self::$n; }
}
M::inc();
echo M::PI, " ", M::inc();Result
3.14 2
Exercise
Class access operator.
Minc()
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.