abstract:<?php$demo1=function($name){ return $name.'最愛的人是:趙敏';};echo $demo1('張無忌'),'<hr>';$belle='周芷若';$demo2=function($name){ return '張無忌最愛的人是:'.$name;};echo $
<?php
$demo1=function($name){
return $name.'最愛的人是:趙敏';
};
echo $demo1('張無忌'),'<hr>';
$belle='周芷若';
$demo2=function($name){
return '張無忌最愛的人是:'.$name;
};
echo $demo2($belle),'<hr>';
$func1=function (){
$name='無忌哥哥';
$test=function() use ($name){
return $name.',我被另一個(gè)函數(shù)包住了,快來救我';
};
return $test();
};
echo $func1(),'<hr>';
$name='無忌哥哥';
$test=function() use ($name){
return $name.',我又被當(dāng)做參數(shù)了,你還要我嗎';
};
$func2=function (callable $test){
return $test();
};
echo $func2($test),'<hr>';
$func3=function (){
$name='無忌哥哥';
//在函數(shù)中聲明一個(gè)匿名函數(shù)
$test=function() use ($name){
return $name.',我又被當(dāng)做返回值了';
};
);
return $test;
};
echo $func3()(),'<hr>';
Correcting teacher:查無此人Correction time:2019-05-22 09:22:56
Teacher's summary:完成的不錯(cuò)。下面應(yīng)該就學(xué)到類了,就會(huì)對php有更深的理解。繼續(xù)加油