最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
PHP 面向对象 final类与final方法
时间:2022-07-02 09:24:28 编辑:袖梨 来源:一聚教程网
Fatal error: Class SuperMath may not inherit from final class (Math) in E:PHPProjects est.php教程 on line 14
//声明一个final类Math
class Math{
public static $pi = 3.14;
public function __toString(){
return "这是Math类。";
}
public final function max($a,$b){
return $a > $b ? $a : $b ;
}
}
//声明类SuperMath 继承自 Math类
class SuperMath extends Math {
public final function max($a,$b){}
}
//执行会出错,final方法不能被重写。
?>
//声明一个final类Math
final class Math{
public static $pi = 3.14;
public function __toString(){
return "这是Math类。";
}
}
$math = new Math();
echo $math;
//声明类SuperMath 继承自 Math类
class SuperMath extends Math {
}
//执行会出错,final类不能被继承。
?>
Fatal error: Class SuperMath may not inherit from final class (Math) in E:PHPProjects est.php on line 16
相关文章
- 窃贼地精联机卡了怎么办?窃贼地精联机失败最新解决方法 07-27
- 万达影城app能改签吗 操作方法介绍 07-27
- 逆战未来雷霆之影 逆战未来雷霆之影最强搭配与实战技巧指南 07-27
- 逆战未来昆仑神宫 逆战未来昆仑神宫玩法解析与实战技巧 07-27
- 逆战未来竞技模式 逆战未来竞技模式玩法详解与上分技巧 07-27
- 逆战未来伯特的审判 逆战未来伯特的审判玩法解析与实战评测 07-27