[PHP] PHP作用域限定符双冒号::的用法 父类方法 →→→→→进入此内容的聊天室

来自 , 2020-05-29, 写在 PHP, 查看 103 次.
URL http://www.code666.cn/view/5812f924
  1.  
  2. <?php
  3. class Fruit
  4. {
  5.     protected function showColor() {
  6.         echo "Fruit::showColor()\n";
  7.     }
  8. }
  9. class Apple extends Fruit
  10. {
  11.     // Override parent's definition
  12.     public function showColor()
  13.     {
  14.         // But still call the parent function
  15.         parent::showColor();
  16.         echo "Apple::showColor()\n";
  17.     }
  18. }
  19. $apple = new Apple();
  20. $apple->showColor();
  21. ?>
  22.  

回复 "PHP作用域限定符双冒号::的用法 父类方法"

这儿你可以回复上面这条便签

captcha