【发布时间】:2018-03-31 13:10:12
【问题描述】:
这是我之前发布的用于解决复杂问题的代码。 其背后的逻辑是 - 在递归的每次迭代中,函数应该将已经执行的 $amount 减少 $wa,并计算新的 $wa,以找到新的 $amount,直到系统无法在表中找到 $amount将比结果 $wa 更大,并作为最后一次迭代进行。 代码没有返回任何内容,当尝试开发它时,没有错误,没有回声。我做错了什么?
$wa = 0.001;
$address = $address;
function recursion($wa)
{
$resulte = db_select ('Credit_user','c')
->fields ('c')
->range(0,1)
->orderby('cr_ts', 'ASC')
->condition('c.affected','0','=')
->condition('c.amount','0','!=')
->execute();
foreach($resulte as $item) {
$code = $item->redeem_code;
global $code;
$amounte = $item->amount;
global $amounte;
$wai = $wa - $amounte;
global $wai;
if ($wai < 0){
echo "production code that should operate with different
variations of $amounte and $redeem on last iteration";
return;
}
elseif ($wai >= 0){ echo "production code
that should operate with different variations
of $amounte and $redeem on each iteration";
return;
} else {
function recursion($wa){
}
}
}}
echo $amounte;
echo "<br>";
【问题讨论】:
-
在你的最后一个 else 中,尝试
recursion($wa)而不是function.....