Blogger Information
Blog 15
fans 0
comment 0
visits 8371
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
回调与递归
我们的关系如此狭窄
Original
579 people have browsed it
//回调函数
//全局回调
function callB($name,$age){
    echo 'name:'.$name;
    echo "<br/>";
    echo "age:".$age;
}
$param = ['yyds','101'];
call_user_func_array('callB',$param);
echo "<br>";
//类静态回调
class A{
    public function tes($name,$age){
        echo 'name:'.$name."-age:".$age;
    }
}
call_user_func_array(['A','tes'],$param);
echo "<br>";
//对象回调
class B{
    public function tes($name,$age){
        echo 'name:'.$name."-__age:".$age;
    }
}
call_user_func_array([new B(),'tes'],$param);
echo "<br>";
//匿名回调
call_user_func_array(function ($a,$b){
    echo 'name:'.$a."______age:".$b;
},$param);


//递归函数 一个函数在它的函数体内调用它自身称为递归调用。这种函数称为递归函数
echo "<br>";
function jc($num){
    if($num == 1){
        return 1;
    }else{
        return $num*jc($num - 1);
    }
}
echo '16 的阶乘是:'.jc(16);


Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
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