What is the PHP callback function? how can this problem be solved?

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.