所屬章節(jié)課程:php自訂函數(shù)之匿名函數(shù)
匿名變量沒有函數(shù)名,通過變量加上括號來調(diào)用,這就是匿名函數(shù) <?php function Myself($one,$two,$func){ //Rules that examine if is function,if isn't a function cease this piece of code and return false if(!is_callable($func)){ return false; } // let $one plus $two ,and then pass $one and $two into this function and excute it // $func is a varibale function echo $one+$two+$func($one,$two); } Myself(20,30,function($foo,$bar){ $result=($foo+$bar)*2; return $result; }); ?> 回調(diào)式的匿名函數(shù)就是回調(diào)時調(diào)用的函數(shù)是沒有函數(shù)名的匿名函數(shù)
2018-08-200個贊