zoukankan      html  css  js  c++  java
  • PHP new self与new static

    self refers to the same class whose method the new operation takes place in.

    static in PHP 5.3's late static bindings refers to whatever class in the hierarchy which you call the method on.

    In the following example, B inherits both methods from A. self is bound to A because it's defined in A's implementation of the first method, whereas static is bound to the called class (also see  get_called_class() ).

    class A {
      public static function get_self() {
        return new self();
      }
     
      public static function get_static() {
        return new static();
      }
    }
     
    class B extends A {}
     
    echo get_class(B::get_self()); // A
    echo get_class(B::get_static()); // B
    echo get_class(A::get_static()); // A
    

      

  • 相关阅读:
    在安装了Anaconda+Pycharm怎么导入OpenCV
    JS--ECMAScript
    JS--DOM
    JS-BOM
    浮动 高度塌陷
    CSS2--字体样式
    CSS2--文本样式
    css2--垂直对齐
    css2--背景
    HTML基础
  • 原文地址:https://www.cnblogs.com/flytome/p/5019747.html
Copyright © 2011-2022 走看看