时间:2021-07-01 10:21:17 帮助过:19人阅读
final关键字只能用来定义类和定义方法。
使用final关键字标记的类不能被继承
final class Person{
.......
}
class Student extends Person{
.......
}会出现错误提示。Fatal error :Class Student may not inherit from final class(Person)
使用final关键字标记的方法不能被子类覆盖
class Person{
final function Say(){
......
}
}
class Student extends Person{
function Say(){
......
}
}
会出现下面错误:
Fatal Error:Cannot Override final method Person::say()
以上就是php中final关键字用法分析内容,更多相关文章请关注PHP中文网(www.gxlcms.com)!