Home > Backend Development > PHP Tutorial > trait 和abstract的区别在哪里、

trait 和abstract的区别在哪里、

WBOY
Release: 2016-06-06 20:22:27
Original
1478 people have browsed it

感觉没区别呢,实在没想出来在那种场景下会有区别

回复内容:

感觉没区别呢,实在没想出来在那种场景下会有区别

无法在一个class上extend多个abstract class,但是你可以use多个trait

abstract class是在类型系统上做文章,trait片段是mixin

类型约束 代码复用
class
interface
trait
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