In computer programming, binding time describes when an association is made in software between two data or code entities. This may occur either before or after execution starts. Early (a.k.a. static) binding occurs before the program starts running and cannot change during runtime. Late (a.k.a. dynamic or virtual) binding occurs as the program is running. Binding time applies to any type of binding including name, memory (i.e. via malloc), and type (i.e. for literals).
The following Java code demonstrates both binding times. The method is early-bound to the code block that follows the function declaration on line 3. The call to is late-bound since <code>List</code> is an interface, so <code>list</code> must refer to a subtype of it. <code>list</code> may reference a <code>LinkedList</code>, an <code>ArrayList</code>, or some other subtype of <code>List</code>. The method referenced by <code>add</code> is not known until runtime.
Late static binding is a variant of binding somewhere between static and dynamic binding. Consider the following PHP example:
In this example, the PHP interpreter binds the keyword <code>self</code> inside <code>A::hello()</code> to class <code>A</code>, and so the call to <code>B::hello()</code> produces the string "hello". If the semantics of <code>self::$word</code> had been based on late static binding, then the result would have been "bye".
Beginning with PHP version 5.3, late static binding is supported. Specifically, if <code>self::$word</code> in the above were changed to <code>static::$word</code> as shown in the following block, where the keyword <code>static</code> would only be bound at runtime, then the result of the call to <code>B::hello()</code> would be "bye":