Relative namespaces and call_user_func()

前端 未结 2 376
猫巷女王i
猫巷女王i 2020-12-20 18:45

Code speaks better than words:

namespaces.php:



        
2条回答
  •  天命终不由人
    2020-12-20 19:43

    You have to use the fully qualified classname in callbacks.

    See Example #3 call_user_func() using namespace name

    I believe this is because call_user_func is a function from the global scope, executing the callback from the global scope as well. In any case, see first sentence.

    Also see the note aboveExample #2 Dynamically accessing namespaced elements which states

    One must use the fully qualified name (class name with namespace prefix).

提交回复
热议问题