How would I initialize a subclass from a parent static method?
I could get subclass’s static variable using late static binding in PHP 5.3 and the static keyword in a parent class’s methods. How would I initialize a new instance of a subclass in a parent static method?
Thanks.
You don’t need to involve static variables or anything that messy. Here’s the shortest example I can come up with:
if you call
b::foo()you will get a new b.