This project is read-only.

What is a "Closure"?
A closure is actually a no-name function. So it is usage principles and syntax is as same as any other functions in php.

Example

$closure = function($a){ return $a*2; }

more examples can be found at: http://php.net/manual/en/functions.anonymous.php

What is "use" identifier in closures?
"use" is a new syntax token for any function, that allows to pass any scope parameter to function and use it as in scope.

Example

$k = 5;
$closureWithUse = function($a)use($k){ return $a*$k; }

Last edited Mar 29, 2011 at 9:50 PM by mowa, version 1

Comments

No comments yet.