RT is {code...}, and {code...}. What is the difference between the two? What should I do if I want to see the source code implementation? A great way to answer this question! RT
One is
$class->$func()
The other 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 are the differences between the two types? What should I do if I want to see the source code implementation? A great way to answer this question!
Reply content:
RT
One is
$class->$func()
The other 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 are the differences between the two types? What should I do if I want to see the source code implementation? A great way to answer this question!
We recommend that you first install an extension to view the opcode and compare the generated opcode. This should be the fastest way to understand the differences between codes. You can use this method for many different things you want to know, such as how print and echo are different.
Just as many c/c ++ programmers often observe the compiled code generated by the compiler when optimizing code, if some php writing styles affect performance, you can also obtain the answer by checking the opcode.
There is not much difference. It is to find the corresponding function from the header of the symbol table and then call it.
You can refer to the php source code php-5.xxxxx/Zend/zend_execute_API.c call_user_function implementation of this function.
Not much
$ Class-> $ func (). If $ func does not exist, a fatal Error is reported.
While call_user_func (array ("class", "func") reports Warning
Then you can know how to select an application scenario in the project.
Call_user_func () is used in a few cases. call_user_func_array () is used in many cases. It is usually used for function calling when function parameters are not scheduled.