Im试图在我的循环完成时返回true,但似乎没有发生。 我可以让它回应真或假或任何文字,但返回什么都不做。可以回显true,但不会返回
不知道是否有人可以解释为什么这是。
这里是(有点)功能,我已经删除了数据库调用,如它并不重要。
function loop_me(){
// this part is not important...
$finished = false;
$done = 0;
$userC = 1000;
$page = 0;
$count = 10;
$array = array()
$data = array('1','2','3') // big array of data...
if($done < $userC){
for($i=0; $i<$count; $i++){
$array[] = $data[$i];
}
// bellow is the important part...
if($done >= $userC){
$finished = true;
}else{
$page++;
loop_me();
}
}
if($finished){
// If I echo true it outputs 1 (this is fine)
// if I return true I get nothing this is got good as I want to do an IF statement on the
// output, which I can't do if it does not.
echo(true);
}
}
好了,所以这个问题的功能之上,但只是为了帮助你,函数的基本想法是,我环路认为数据的阵列(以上未showen),但该数据分页所以需要在第一页和那几页完成后才能进入下一个“页面”,所以我想要做的是在完成循环时认为它都返回true。
可能是一个简单的修复。
但我无法解决这个问题。
这是通过AJAX调用吗?这可以解释为什么你看到回声声明但不返回值。 – 2013-04-05 21:40:44