类型
修饰关键字
类(class)
抽象类(abstract class)
接口(interface)
属性
public
✔️
✔️
✘
private
✔️
✔️
protected
✔️
✔️
static
✔️
✔️
const
✔️
✔️
方法
public
✔️✔️
✔️
private
✔️
✔️
✘
protected
✔️
✔️
✘
static
✔️
✔️
✔️
final
✔️
✔️
✘
abstract
✘
✔️
✘
类型
修饰关键字
内部访问
子类访问
外部访问
属性
public
$this->
$this-> 如果被重写无法访问
对象->
private
$this->
✘
✘
protected
$this->
$this-> 如果被重写无法访问
✘
static
self::
parent::
类名::
const
self::
parent::
类名::
方法
public
$this->
parent::
对象->
private
$this->
✘
✘
protected
$this->
parent::
✘
static
self::
parent::
类名::
final
$this->
不可被子类重写 访问 parent::
对象->
abstract
✘
只有声明没有实现,子类中必须实现
根据抽象方法的具体修饰符而定注意不能为private
除了 普通类 、抽象类和接口外,还有一种特殊的类。final关键字声明的类(最终类)
该类不能被子类继承, 但可以有父类和实现接口