I understand what both Lambda and Closure functions represent, but I don't understand the need for Closure functions.
What's the need for Closure functions if we can just pass the variable to the Lambda functions. It looks like it's easier to write the variable name when calling the function, than writing 'use' and then defining it.
For example, these two will do exactly the same:
$string = 'string'; $lambda = function($string) { echo $string; }; $lambda($string); $string = 'string'; $closure = function() use ($string) { echo $string; }; $closure(); ...and in my understanding, the first block of code is Anonymous (Lambda) function, and the second one is Closure. Also, changing the variable inside the function will not affect the variable outside of it in both ways.
I've found a lot of questions about the differences, but none of them explained the need for it.
Thank you for answers.