php中类的继承

WBOY
Release: 2016-06-23 13:22:53
Original
1446 people have browsed it

1、子类继承父类用extends关键字

2、子类只能继承自一个父类,但父类可以继承自另一个类

3、继承时,可以继承父类的公共/保护的属性和方法,不能继承私有的属性和方法

4、子类中,可以声明与父类同名的属性和方法进行覆盖,但继承的权限只能是相同或者越来越宽松,不能越来越严格,比如父类中声明protected $a,则子类中不能声明private $a,只能是用public或者protected

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template