【发布时间】:2012-10-31 22:17:58
【问题描述】:
我将此代码与 php 一起使用:
while (0 != $date1 || $this->counter < 5 ) {
// if ($this->true_cahce_failure ) {
$this->url= $this->adjust_url_with_www_add($this->url);
// $this->counter=2;
// }
$this->cache_debug("Date".$date1." ".$this->url,"Recursion ".$this->counter);
$date1 = $this->get_date();
$this->counter++;
}
$this->cache_debug("Date: ".$date1." ".$this->url,"Loop Done ");
基本上循环应该一直持续到$date 为not 0 或counter 不大于5。有时date1 有0,但有时没有。如果不是,它应该在 while 评估中返回,并停止迭代。但它并没有这样做,迭代仍在继续。
只有当计数器达到 5 时才会停止。这是为什么呢?
【问题讨论】:
标签: php recursion while-loop conditional-statements