Php While语句无限循环

Php While语句无限循环,php,while-loop,Php,While Loop,我一辈子都搞不懂为什么这个函数在一个无限循环中。这可能是我没有看到的简单的东西。给出年份,然后从7/[开始年份]到本月每月打印一次 function showmonths($year) { $start = strtotime($year.'-07-01'); $end = strtotime("now"); while($end >= $start) { $months[] = strtotime("-1 month", $end); $end = str

我一辈子都搞不懂为什么这个函数在一个无限循环中。这可能是我没有看到的简单的东西。给出年份,然后从7/[开始年份]到本月每月打印一次

function showmonths($year) {

    $start = strtotime($year.'-07-01');
    $end = strtotime("now");

while($end >= $start) {
   $months[] = strtotime("-1 month", $end);
   $end = strtotime("-1 month", $end);
}
return $months; 
}

这个函数看起来很奇怪,但它至少不是一个无止境的循环。这个函数对我来说不是无限循环的,而且工作正常。问题一定在代码的其他地方。提示:您可以使用
$months[]=$end=strotime(“-1个月”,“$end”)改为
$months[]=strottime(“-1个月,$end”)$end=strottime(“-1个月,$end”)