Home > Backend Development > PHP Tutorial > 关于回调函数无法显示的help

关于回调函数无法显示的help

WBOY
Release: 2016-06-23 14:12:55
Original
969 people have browsed it

回调函数

function filter(){
for($i=0;$i if(call_user_func_array('one',array($i))){
continue;
echo $i."
";
}
}
}

function one($num){
return $num%3==0;
}

echo filter();



为什么这段代码无法显示的,我注释掉一些代码,循环都是正常的,求高手!

回复讨论(解决方案)

把 continue; 去掉就可以显示了

但是去掉之后,3的倍数就显示出来了啊 ,我要它不显示3的倍数啊

$num%3==0 不就是 3 的倍数吗?

你最好先描述一下你的需求

我想循环出0-100的数字,然后利用回调函数过滤掉3的倍数

function filter(){  for($i=0;$i<=100;$i++){    if(call_user_func_array('one',array($i))){      echo $i."<br>";	    }  }}function one($num){  return $num % 3;}echo filter();
Copy after login

为什么不用contiune的呢 亲

你想用 contiune ?那么

function filter(){  for($i=0;$i<=100;$i++){    if(call_user_func_array('one',array($i))){      contiune;    }    echo $i."<br>";      }} function one($num){  return $num % 3 == 0;} echo filter();
Copy after login

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template