2017-02-06 124 views
0

有人可以幫助我理解此循環的邏輯。我是新來的PHP和從教程製作日曆。如果條件對我來說不清楚的話,這個邏輯。下面是代碼瞭解日曆的代碼邏輯PHP

if($running_day == 6): 
     $calendar.= '</tr>'; 
     if(($day_counter+1) != $days_in_month): 
      $calendar.= '<tr class="calendar-row">'; 
     endif; 
     $running_day = -1; 
     $days_in_this_week = 0; 
    endif; 

解密最難行:

$calendar.= '<tr class="calendar-row">'; 

任何幫助,將不勝感激。

+1

在哪一行以及哪一部分你不明白。 – C2486

+0

第二個條件,難以解密。當這個嵌套條件成立時,我不明白會發生什麼。 – Seeker

回答

1

此代碼:

if(($day_counter+1) != $days_in_month): 
     $calendar.= '<tr class="calendar-row">'; 
    endif; 

它實際上加時1至天計數器變量不等於天,一個月後的變量中創建你的表新行。

希望它有幫助!

+0

因此,正在添加一個新行! – Seeker

+0

非常感謝。現在我真的瞭解並可以控制日曆的行爲 – Seeker