Passing static methods as arguments in PHP

前端 未结 7 1404
温柔的废话
温柔的废话 2021-02-02 07:34

In PHP is it possible to do something like this:

myFunction( MyClass::staticMethod );

so that \'myFunction\' will have a reference to the stati

相关标签:
7条回答
  • 2021-02-02 08:26

    As of PHP 7.4, this is convenient and IDE-friendly:

    myFunction(fn() => MyClass::staticMethod());
    
    0 讨论(0)
提交回复
热议问题