new self
And new static
the difference: Both are instances of itself, except that the inheritance. If there is no inheritance, the instances returned by both belong to the same class; if there is inheritance, the subclass calls this method and new self
still returns an instance of the original class, but new static
returns an instance of the actual subclass. This is delayed static binding. The value of static uses the class that actually called the method last.
The difference between new self and new static in the PHP framework (to be continued)
Guess you like
Origin blog.csdn.net/EasyTure/article/details/112865912
Recommended
Ranking