I have the following code, unfortunately it's looping infinity but I can't understand why :
$tot_age is
set to 604245119
while ($tot_age > 536467742) {
$tot_age - 31536000;
if ($tot_age < 536467742 ) {
// do something
break;
}
}
So what I'm attempting to here is the following. If $tot_age
is greater than 17 years, iterate through the loop and minus 12 months from $tot_age. I'm then attempting to break out of the loop at the point which $tot_age is less than 17 years. I'll apply some logic here too.
Can anyone see an issue here? Thanks
Use it like this:
while ($tot_age > 536467742) {
$tot_age = $tot_age - 31536000;
if ($tot_age < 536467742 ) {
// do something
break;
}
}
第二行应显示为
$tot_age = $tot_age - 31536000;
Youre not changing the value of tot_age in the loop, you're just making an empty statement. Change:
$tot_age - 31536000;
to:
$tot_age = $tot_age - 31536000;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.