从PHP匿名函数访问变量

问题描述:

我有以下带有静态变量的类.如何从匿名PHP函数中访问类的静态函数?

I have the following class with static variables. How can I access the static functions of a class from within an anonymous PHP function?

class MyClass {
  public static function MyFunction(mylocalparam){
      MyStaticClass:MyStaticMethod(function(myparam) use(mylocalparam){
         MyClass::MyFunction2(mylocalparam);
   });
  }

  private static function MyFunction2(someobject){
  }
}

我无法从匿名类中访问函数"MyFunction2".您能否提出建议以解决此问题?

I am having trouble accessing the function "MyFunction2" from within the anonymous class. Could you please advice on how to rectify this?

不会发生.您需要使静态函数public.匿名函数不在MyClass的范围内运行,因此无法访问其中包含的private方法.

Not going to happen. You need to make the static function public. The anonymous function doesn't run inside the scope of MyClass, and therefore doesn't have access to private methods contained within it.