In this tutorial (), it is called:
preserved: method or variable With protected visibility can only be reached in derivative organs. Or preserved in the second term in the children's class will be used in the process of inheritance.
Here it is said:
Protected can be accessed within the orbit only and the guardian class.
We often use preserved in heritage classes, so I wonder how it works: can be protected by parents classes Can someone give me examples? Thank you.
protected actually allows any section in the legacy chain access . In fact, there is only one case where a child's property or method should be used by parents: Parents declare aprotected method and children override saysquare fu {public function bar () {$ this-> Baz (); } Protected Function Falcon () {}} class protects hair follower (safe function falcon) {echo 'ha!'; }}When the phone calls
$ child-> the bar () , then it is necessary thatFoo :: bar Usehair :: baz . Parents should not "know" about their children in any other way and therefore there is no need to reach some of them.
No comments:
Post a Comment