What is the PHP callback function? Baidu: a lot of callbacks are called by function pointers. Next, I will talk about it step by step. Finally, it comes down to the C language. it's speechless! Is this callback so hard to understand? What is the key to Callback? Some people understand that this is another function called inside the function. I don't think so. Instead, I call myself, just like the loop proof in the mathematical logic, such as the condition ............ Verify: AB. sometimes we make such a verification error: What is the B PHP callback function?
Baidu once said that a lot of callbacks are called back using function pointers. Then, one step at a time, it comes down to the C language. it's speechless! Is this callback so hard to understand?
What is the key to Callback? Some people understand that this is another function called inside the function. in my opinion, this is not the case. Instead, I call myself, just like the loop proof in the mathematical logic, such
Conditions ............ Verification: a = B;
Sometimes we will make such a verification error: Because B = a, so a = B, I believe that all people have made similar mistakes.
The callback function is similar to this in my understanding,
Function fn ($ ){
$ B = m;
$ C = $ B + fn ($ B );
Return;
}
I don't know what I understand, right?
Share: More
------ Solution --------------------
Your understanding is wrong!
Call a callback instead of calling a callback.
You also know that the key to callback is this callback.
Since it is a callback, there is a question about who is the subject, because the callback is called back.
I called function A, and function A called function B during execution. function B is called the callback function of function.
Obviously, the subject is function.
We know that a function is a set of code that completes a specific function. During function execution, it generally cannot interfere with its behavior.
When a function is designed with a callback function, we may intervene in the function during its execution. For example
Function foo ($ n, $ f = ''){
If ($ n <1) return;
For ($ I = 0; $ I <$ n; $ I ++ ){
Echo $ f? $ F ($ I): $ I;
}
}
// When no callback exists
Foo (5); // 01234.
// When callback exists
Function f1 ($ v ){
Return $ v + $ v;
}
Foo (5, 'F1'); // 02468