I use this code with 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 ");
Basically the loop should continue until either $date is not 0 or counter isn’t bigger than 5. Sometimes the date1 has got 0 but sometimes not. When it doesn’t it should return in the while evaluation, and stop the iteration. But it doesn’t do so and the iteration continues.
It only stops with counter reaches 5. Why is that?
It’s likely not stopping because your
$this->counteris still< 5when$date1is not0. If you look at those statements in theirtrue/falsevalues, yourwhilecondition becomes:while
$this->counteris< 5and for any values of$date, which would make the execution continue.You likely want to switch it to
Using
&&because you want both conditions to betrue, not just one. Also switching the!=to==when comparing the date to0so it will also stop when you have a non-0 date.