PHP AdvancedLesson 40Free preview
PHP Callback Functions
This lesson is part of PHP · All levels
Summary
A callback is a function that is continued as an argument to another function to be called in. This pattern is widely used in array functions such as array_walk(), usort(), and array_map(). You also know how to call a function by its name in the form of a string.
Key points
- Callback is a function that is sent as an argument to run another function
- The callback name can be written as a string or a closure.
- Array_walk() and usort() receive callbacks to process array elements
- Call_user_func() calls a function based on the name stored in the string
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.