Skip to main content

What is a callback function in PHP?

Junior PHP
Quick Answer A callback is a function passed as an argument to another function. PHP accepts closures, arrow functions, function name strings, or array with object+method. Used with array_map(), array_filter(), usort(), etc. Callbacks let you customize behavior without changing the function. Closures can capture outer variables using the use keyword.

Answer

A callback is a function passed as an argument and executed inside another function.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice