函数与闭包的作业

原创 2018-12-25 11:40:32 155
摘要:function demo(){    $a=10;    $b=20;    $c = function ($text)use($a,$b) //使用use调用demo中的变量 $a $b    {        echo $text.($a+$b);    

function demo(){
   $a=10;
   $b=20;

   $c = function ($text)use($a,$b) //使用use调用demo中的变量 $a $b
   {

       echo $text.($a+$b);


   };
    return $c; //返回值$c
};
$var = demo();  //把demo 赋值给 $var

$var('$a跟$b的和是:');



批改老师:韦小宝批改时间:2018-12-25 11:52:34
老师总结:写的稍微有点简洁了!不过写的还是不错的!课后记得要多加练习才可以哦!

发布手记

热门词条