Home  >  Article  >  Backend Development  >  php中类的继承_PHP教程

php中类的继承_PHP教程

WBOY
WBOYOriginal
2016-07-12 09:04:501497browse

php中类的继承

1、子类继承父类用extends关键字
2、子类只能继承自一个父类,但父类可以继承自另一个类
3、继承时,可以继承父类的公共/保护的属性和方法,不能继承私有的属性和方法
4、子类中,可以声明与父类同名的属性和方法进行覆盖,但继承的权限只能是相同或者越来越宽松,不能越来越严格,比如父类中声明protected $a,则子类中不能声明private $a,只能是用public或者protected

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1071709.htmlTechArticlephp中类的继承 1、子类继承父类用extends关键字 2、子类只能继承自一个父类,但父类可以继承自另一个类 3、继承时,可以继承父类的公共...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn