What is Closure in Laravel?

Technology CommunityCategory: LaravelWhat is Closure in Laravel?
VietMX Staff asked 3 years ago

A Closure is an anonymous function. Closures are often used as callback methods and can be used as a parameter in a function.

function handle(Closure $closure) {
    $closure('Hello World!');
}

handle(function($value){
    echo $value;
});