Rt
One is
$class-$func ()
The other one is
Simple Callbackcall_user_func ($func)//static class method Callcall_user_func (Array ($class, $func))//object method Call$class = new MyClass (); Call_user_func (Array ($class, $func));
What is the difference between the two? What if I want to see what the source implementation should do? Answer this question to find a way!
Reply content:
Rt
One is
$class-$func ()
The other one is
Simple Callbackcall_user_func ($func)//static class method Callcall_user_func (Array ($class, $func))//object method Call$class = new MyClass (); Call_user_func (Array ($class, $func));
What is the difference between the two? What if I want to see what the source implementation should do? Answer this question to find a way!
I recommend that you first install an extension that looks at opcode and compare the generated opcode. This should be the quickest to understand the different scenarios between the code. Many of the different things you want to know can be used in this way, such as how print and echo are different, and so on.
Off-topic, just as many C + + programmers optimize code often observe the compiler generated assembly code, whether some of the writing style of PHP will have an impact on performance or by looking at opcode to get answers.
It doesn't make much difference, it is to find the corresponding function from the symbol table head and call it.
can refer to PHP source code PHP-5.XXXXX/ZEND/ZEND_EXECUTE_API.C in the implementation of call_user_function this function.
Not much to say what
$class-$func (), if $func does not exist, is reported fatal Error
The Call_user_func (Array ("Class", "Func")) is reported warning
You'll know how to choose the application scenario in your project.
Call_user_func () is not used in many cases, Call_user_func_array () Use more cases, usually used for function parameters of the function of the call