PHP闭包和高阶函数
<?php
function func($a, $b) {
$line = function ($x) use ($a, $b) {
return $a*$x + $b;
};
return $line;
}
$line1 = func(1, 1);
$line2 = func(3, 4);
$x = 5;
$y1 = $line1($x);
$y2 = $line2($x);
echo "x=$x ---> y1=$y1 , y2=$y2";
?>