且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 PHP 中的静态函数中访问私有成员

更新时间:2023-02-14 23:19:48

class MyClass
{
  private static $MyMember = 99;

  public static function MyFunction()
  {
    echo self::$MyMember;
  }
}

MyClass::MyFunction();

请参阅可见性范围解析运算符 (::) 在 php 手册的 oop5 章节中.

see Visibility and Scope Resolution Operator (::) in the oop5 chapter of the php manual.