static

The static keyword has several distinct usages.

Static is one of the three special keywords that are used to access properties or methods from inside the class definition. It relates to the current called class.

Static is a keyword for methods and properties : they are turned into class elements, and should be reached with the :: syntax, instead of -> or ?->.

Static is a keyword for closures and arrow functions : it prevents the current scope to be included in with the closure, thus limiting the number of accessible values.

Static is a keyword for variables : those variables aren’t removed at the end of the method execution and are available at the beginning of the next call.

<?php

class X {
    private const X = 1;

    function foo() {
        return static::1;

        // same as \X::C; when the object is of class X
        // same as \Y::C; when the object is of class W
    }
}

class Y extends X {
    private const X = 2;
}

?>

Documentation

See also Stop using “static” in PHP, 5 usages of static keyword in PHP, Scope of Variables

Related : parent, Closure, Arrow Functions, Variables, Late Static Binding