static in this case means the area of ββthe current object. It is used in late static binding.
This will usually be the same as using self . The place where it differs is when you have a hierarchy of objects where the reference to the region is determined by the parent, but called on the child. self in this case will refer to the area with parents, while static will refer to the child
class A{ function selfFactory(){ return new self(); } function staticFactory(){ return new static(); } } class B extends A{ } $b = new B(); $a1 = $b->selfFactory(); // a1 is an instance of A $a2 = $b->staticFactory(); // a2 is an instance of B
The easiest way to think of yourself as a defining sphere and static, which is the region of the current object.
Orangepill
source share