您的位置:首页 > 编程语言 > PHP开发

回调函数例题

2017-08-23 21:01 211 查看
//回调函数 把函数的名称作为参数传递到另外一个函数中
function one($n){
if($n%2==0){
return true;
}else{
return false;
}
}
//one(2);
function three($n){
if($n%2==1){
return true;
}else{
return false;
}
}
//three(2);
function two($f){
for($i = 0; $i<=10;$i++){
if($f($i)){//调用one函数/three函数
continue;//跳过循环的
}
echo $i."<br>";
}
}
two("one");
two("three");
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  php 回调函数