3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $currentMonth = date("n"); $currentYear = date("Y"); echo $currentMonth . "\n"; echo $currentYear . "\n"; $month = $currentMonth; $year = $currentYear; $firstDayOfTheMonth = mktime(0, 0, 0, $month, 1, $year); $d = getdate($firstDayOfTheMonth); // Vasarnap helyett hetfo az elso nap a heten. $dayOfTheWeekOfFirstDayOfTheMonth = (6 + $d["wday"]) % 7 + 1; $totalDaysInCurrentMonth = date("t"); $kellenekUresNapokAHonapVegen = true; echo $firstDayOfTheMonth . "firstDayOfTheMonth\n"; //echo $d . "d\n"; echo $dayOfTheWeekOfFirstDayOfTheMonth . "dayOfTheWeekOfFirstDayOfTheMonth\n"; echo $totalDaysInCurrentMonth . "totalDaysInCurrentMonth\n"; for ($i = 0; $i < $totalDaysInCurrentMonth + ($dayOfTheWeekOfFirstDayOfTheMonth - 1); $i++) { // Csak az aktuális héttől kezdve. Megjegyzés: date("W") hétfőt tekinti a hét első napjának, ami nekünk pont megfelel. $day = $i - $dayOfTheWeekOfFirstDayOfTheMonth + 2; echo '$day: ' . $day ."\n"; $dateWeek = date("W", mktime(0, 0, 0, $month, $day, $year)); echo '$dateWeek: ' . $dateWeek ."\n"; if (intval(date("W")) > intval($dateWeek)) { echo "CONTINUE1\n"; continue; } // A hónap végén azokat a heteket nem jelenítjük meg, amikre még nem lehetne jelentkezni. $utolsoJelentkezhetoHet = intval(date("W", strtotime("+ 28 day"))); if (intval(date("W", strtotime("+28 day"))) < intval(date("W"))) { $utolsoJelentkezhetoHet += 52; } echo "utolsoJelentkezhetoHet: " .$utolsoJelentkezhetoHet. "\n"; if (intval($dateWeek) > $utolsoJelentkezhetoHet) { $kellenekUresNapokAHonapVegen = false; echo "CONTINUE2\n"; continue; } if ($i % 7 == 0) { echo "<tr>"; } if ($i < $dayOfTheWeekOfFirstDayOfTheMonth - 1) { // Ures napok a honap elejen. echo "<td class='noborder'></td>"; } else if ($i < $totalDaysInCurrentMonth + $dayOfTheWeekOfFirstDayOfTheMonth - 1){ // Naptari napok. $day = $i - $dayOfTheWeekOfFirstDayOfTheMonth + 2; $date = date("Y-m-d", mktime(0, 0, 0, $month, $day, $year)); $napiJelentkezok = isset($napiJelentkezokSzama[$date]) ? $napiJelentkezokSzama[$date] : 0; if (isset($jelentkezettNapok[$date])) { if (isDayInTheFuture($date)) { echo "<td title='Klikkelj a lemondáshoz' id='nap-".$date."' class='registered' onclick='lemondasMegerositese(\"".$date."\")'><span class='notToday'>".$day."</span>".getNapiJelentkezokHtml($napiJelentkezok)."</td>"; } else { if (isToday($date)) { echo "<td id='nap-".$date."' class='todayRegistered today'><span class='today'>".$day."</span>".getNapiJelentkezokHtml($napiJelentkezok)."</td>"; } else { echo "<td id='nap-".$date."' class='pastRegistered'><span class='notToday'>".$day."</span>".getNapiJelentkezokHtml($napiJelentkezok)."</td>"; } } } else { if (isToday($date)) { echo "<td id='nap-".$date."' class='notAvailableForRegistration today'><span class='today'>".$day."</span>".getNapiJelentkezokHtml($napiJelentkezok)."</td>"; } else { echo "<td title='Klikkelj a jelentkezéshez' id='nap-".$date."' " .(isDayAvailableForRegistration($date, $jelentkezettNapok) ? "class='availableForRegistration' onclick='jelentkezesMegerositese(\"".$date."\")'><span class='notToday'>".$day."</span>".getNapiJelentkezokHtml($napiJelentkezok)."</td>" : "class='notAvailableForRegistration'><span class='notToday'>".$day."</span></td>"); } } } else { // TODO(palinko): Kell ez? echo "<td class='noborder'></td>"; } if ($i % 7 == 6) { echo "</tr>"; } } ?>
Output for 7.0.0 - 7.1.0
12 2012 1354316400firstDayOfTheMonth 6dayOfTheWeekOfFirstDayOfTheMonth 31totalDaysInCurrentMonth $day: -4 $dateWeek: 48 CONTINUE1 $day: -3 $dateWeek: 48 CONTINUE1 $day: -2 $dateWeek: 48 CONTINUE1 $day: -1 $dateWeek: 48 CONTINUE1 $day: 0 $dateWeek: 48 CONTINUE1 $day: 1 $dateWeek: 48 CONTINUE1 $day: 2 $dateWeek: 48 CONTINUE1 $day: 3 $dateWeek: 49 utolsoJelentkezhetoHet: 53 <tr> Fatal error: Uncaught Error: Call to undefined function isToday() in /in/qCrPP:68 Stack trace: #0 {main} thrown in /in/qCrPP on line 68
Process exited with code 255.
Output for 5.0.0 - 5.6.28
12 2012 1354316400firstDayOfTheMonth 6dayOfTheWeekOfFirstDayOfTheMonth 31totalDaysInCurrentMonth $day: -4 $dateWeek: 48 CONTINUE1 $day: -3 $dateWeek: 48 CONTINUE1 $day: -2 $dateWeek: 48 CONTINUE1 $day: -1 $dateWeek: 48 CONTINUE1 $day: 0 $dateWeek: 48 CONTINUE1 $day: 1 $dateWeek: 48 CONTINUE1 $day: 2 $dateWeek: 48 CONTINUE1 $day: 3 $dateWeek: 49 utolsoJelentkezhetoHet: 53 <tr> Fatal error: Call to undefined function isToday() in /in/qCrPP on line 68
Process exited with code 255.
Output for 4.4.5 - 4.4.9
12 2012 1354316400firstDayOfTheMonth 6dayOfTheWeekOfFirstDayOfTheMonth 31totalDaysInCurrentMonth $day: -4 $dateWeek: 48 CONTINUE1 $day: -3 $dateWeek: 48 CONTINUE1 $day: -2 $dateWeek: 48 CONTINUE1 $day: -1 $dateWeek: 48 CONTINUE1 $day: 0 $dateWeek: 48 CONTINUE1 $day: 1 $dateWeek: 48 CONTINUE1 $day: 2 $dateWeek: 48 CONTINUE1 $day: 3 $dateWeek: 49 utolsoJelentkezhetoHet: 53 <tr> Fatal error: Call to undefined function: istoday() in /in/qCrPP on line 68
Process exited with code 255.
Output for 4.3.2 - 4.4.4
12 2012 1354316400firstDayOfTheMonth 6dayOfTheWeekOfFirstDayOfTheMonth 31totalDaysInCurrentMonth $day: -4 $dateWeek: 48 CONTINUE1 $day: -3 $dateWeek: 48 CONTINUE1 $day: -2 $dateWeek: 48 CONTINUE1 $day: -1 $dateWeek: 48 CONTINUE1 $day: 0 $dateWeek: 48 CONTINUE1 $day: 1 $dateWeek: 48 CONTINUE1 $day: 2 $dateWeek: 48 CONTINUE1 $day: 3 $dateWeek: 49 utolsoJelentkezhetoHet: 53 <tr> Fatal error: Call to undefined function: istoday() in /in/qCrPP on line 68
Process exited with code 255.
Output for 4.3.0 - 4.3.1
12 2012 1354316400firstDayOfTheMonth 6dayOfTheWeekOfFirstDayOfTheMonth 31totalDaysInCurrentMonth $day: -4 $dateWeek: 48 CONTINUE1 $day: -3 $dateWeek: 48 CONTINUE1 $day: -2 $dateWeek: 48 CONTINUE1 $day: -1 $dateWeek: 48 CONTINUE1 $day: 0 $dateWeek: 48 CONTINUE1 $day: 1 $dateWeek: 48 CONTINUE1 $day: 2 $dateWeek: 48 CONTINUE1 $day: 3 $dateWeek: 49 utolsoJelentkezhetoHet: 53 <tr> Fatal error: Call to undefined function: istoday() in /in/qCrPP on line 68