I hope the moderator can provide great guidance on the writing of dynamic and static method calls in PHP.
Db ;}} class B extends A {static function ex () {self: getInstance ()-> find () ;}}$ B = new B (); $ B-> find (); echo"
"; // Method B: ex ();?>
According to the description of the moderator, I modified it a little and made the current effect, but I don't quite understand it, because I am also confused and don't understand the specific principle.
First, I want to keep the find method in Class A written with the $ this pointer instead of self.
As in the following two call methods:
The first method dynamically calls the find method. Obviously, the output is OK.
The second type is the static class that calls the static method first. is The Returned "static instantiation object "?
And then call the find method. I don't know much about it. why is the $ this pointer changed?
The purpose of this writing is to allow external code to dynamically call or statically call methods in Class,
It's a bit confused,
Can the moderator organize the running principles?
Reply to discussion (solution)
Add one sentence below $ B = new B ();
$ B-> db = 2;
We can see that although it is a class, it contains two systems