Inheritance of classes in php_PHP tutorial

WBOY
Release: 2016-07-12 09:04:50
Original
1517 people have browsed it

Inheritance of classes in php

1. Subclasses inherit from parent classes using the extends keyword.
2. A subclass can only inherit from one parent class, but a parent class can inherit from another class
3. When inheriting, you can inherit the public/protected attributes and methods of the parent class, but you cannot inherit the private attributes and methods
4. In a subclass, you can declare attributes and methods with the same name as those of the parent class for overriding, but the inherited permissions can only be the same or become more and more relaxed, and cannot become more and more strict. For example, the parent class declares protected $a , then private $a cannot be declared in the subclass, only public or protected

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1071709.htmlTechArticleInheritance of classes in php 1. Subclasses inherit from parent classes using the extends keyword 2. Subclasses can only inherit from A parent class, but the parent class can inherit from another class 3. When inheriting, you can inherit the public of the parent class...
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!