国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > PHP > 正文

PHP 面向對象 final類與final方法

2024-09-04 11:43:46
字體:
來源:轉載
供稿:網友

Fatal error: Class SuperMath may not inherit from final class (Math) in E:PHPProjects est.php on line 14

  1. <?php 
  2. //聲明一個final類Math  
  3. class Math{  
  4. public static $pi = 3.14;  
  5. public function __toString(){  
  6. return "這是Math類。";  
  7. }  
  8. public final function max($a,$b){  
  9. return $a > $b ? $a : $b ;  
  10. }  
  11. }  
  12. //聲明類SuperMath 繼承自 Math類  
  13. class SuperMath extends Math {  
  14. public final function max($a,$b){}  
  15. }  
  16. //執行會出錯,final方法不能被重寫。 
  17.  
  18. ?>  
  19. <?php 
  20. //聲明一個final類Math  
  21. final class Math{  
  22. public static $pi = 3.14; 
  23.  
  24. public function __toString(){  
  25. return "這是Math類。";  
  26. }  
  27. }  
  28. $math = new Math();  
  29. echo $math
  30.  
  31. //聲明類SuperMath 繼承自 Math類  
  32. class SuperMath extends Math {  
  33. //開源代碼Vevb.com 
  34. //執行會出錯,final類不能被繼承。 
  35.  
  36. ?> 

Fatal error: Class SuperMath may not inherit from final class (Math) in E:PHPProjects est.php on line 16

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 昌图县| 六盘水市| 阿图什市| 阜康市| 沂南县| 大竹县| 景德镇市| 玉门市| 芜湖市| 梁平县| 南投县| 隆德县| 黄陵县| 隆昌县| 仁化县| 绥芬河市| 大丰市| 农安县| 华池县| 佳木斯市| 九寨沟县| 周宁县| 兴安县| 怀安县| 宝兴县| 习水县| 玛沁县| 鄂托克旗| 吉林市| 麟游县| 镇雄县| 稻城县| 枝江市| 四子王旗| 苍梧县| 科尔| 黄陵县| 册亨县| 鄄城县| 巫山县| 龙陵县|