Closures in PHP 5.3

Anscheinend wird es in PHP 5.3 closures geben:

/* Returns true if $tOne and $tTwo are both evenly

 divisible by the denominator ($denom) */

function EvenlyDivisible($denom, $tOne, $tTwo)

{

 $evenlyDivisible = function ($testNum) use ($denom) {

 //Note that $denom is defined outside closure scope

 if (($testNum % $denom) == 0)

 {

 return true;

 }

 else

 {

 return false;

 }

 };

 //Use the closure as necessary

 if ($evenlyDivisible($tOne) && ($evenlyDivisible($tTwo)))

 {

 return true;

 }

 else

 {

 return false;

 }

}

Possibly related posts (automatically generated)