Access control inherited by {PHP} PHP when it comes to inheritance, you have to mention access control. Inheritance varies with access control permissions. Taking the member method as an example, we can use the private and protected access modifiers to control the content to be inherited. Private if a member... SyntaxHighlighter. all (
Access control inherited by {PHP} PHP
When it comes to inheritance, we have to mention access control. Inheritance varies with access control permissions. Taking the member method as an example, we can use the private and protected access modifiers to control the content to be inherited.
Private: if a member is specified as private, it cannot be inherited. In fact, this method will be inherited in PHP, but it cannot be accessed.
Protected if a member is specified as protected, it is invisible outside the class and can be inherited.
Let's look at a PHP example:
Class Base {
Private function privateMethod (){
}
}
Class Child extends Base {
Public function publicMethod (){
}
}
$ C = new Child ();
If (method_exists ($ c, 'privatemethod ')){
Echo 1;
} Else {
Echo 0;
}
By bill200711022