Blogger Information
Blog 12
fans 0
comment 0
visits 6654
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
可变函数/回调函数
虎哥的学习日志
Original
731 people have browsed it

函数名是一个变量的函数叫可变函数

function add($a,$b){return $a+$b;}

function sub($a,$b){return $a-$b;}

function mult($a,$b){return $a*$b;}

function div($a,$b){return $a/$b;}

$funcName='add';

echo $funcName(20,5);//$funcName一个变量,相当于调用了add(20,5);

// call_user_func_array(可变函数名,参数列表数组)

function back($funcName,$a,$b){//回调函数

return call_user_func_array($funcName,[$a,$b]);

}

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post