{{PHP}} PHP inherited access Control _php tutorial

Source: Internet
Author: User
{{PHP}} Access Control for PHP inheritance

When it comes to inheritance, you have to mention access control. Inheritance has different performance under different access control permissions. In the case of member methods, we can use the private and protected access modifiers to control what needs to be inherited.

Private if a member is specified as private, it cannot be inherited. In fact, in PHP this method will be inherited, but not accessible.
Protected if a member is specified as protected, it will not be visible outside the class and can be inherited.

See an example of PHP:

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;
}


Author: bill200711022

http://www.bkjia.com/PHPjc/478062.html www.bkjia.com true http://www.bkjia.com/PHPjc/478062.html techarticle {{php}}php inherited access control when it comes to inheritance, you have to mention access control. Inheritance has different performance under different access control permissions. Take the member method as an example, we can make ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.