使用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开发笔记 (http://phpvi.com/) | Powered by Discuz! 6.1.0 |