zoukankan      html  css  js  c++  java
  • php相关知识总结

    class Father{
        public static function getStatic(){
            return new static();
        }
        public static function getSelf(){
            return new self();
        }
    }
    trait GrandFather{
        public static function getStatic(){
            return new static();
        }
        public static function getSelf(){
            return new self();
        }
    }
    class Son1{
     use GrandFather;
    }
    class Son2 extends Father {
    
    }
    $o1 = Son1::getStatic();
    $o2 = Son2::getStatic();

    new static和new self的表现,self时是new父类自己,static是代表当前子类且在使用extend和trait时效果一样

  • 相关阅读:
    CentOS 6.x 系统安装选项说明
    MySQL表的操作
    6月13号
    6月11号
    6月10号
    6月9号
    6月6
    day27
    day 28
    day 29
  • 原文地址:https://www.cnblogs.com/zhiguopingtianxia/p/14531693.html
Copyright © 2011-2022 走看看