3v4l.org

run code in 300+ PHP versions simultaneously
<?php print_r(getMonth(null)); echo ':::'; print_r(getQuarter(null)); echo ':::'; print_r(dtf(null)); function getMonth($d) { return dtf($d,'n'); } function getQuarter($d) { return ceil( getMonth($d) / 3); } function dtf($date, $format = 'd.m.Y'){ if($date) $date = new DateTime($date); return $date->format($format); }
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Fatal error: Uncaught Error: Call to a member function format() on null in /in/sT2Ns:22 Stack trace: #0 /in/sT2Ns(11): dtf(NULL, 'n') #1 /in/sT2Ns(3): getMonth(NULL) #2 {main} thrown in /in/sT2Ns on line 22
Process exited with code 255.
Output for 5.6.8 - 5.6.28
Fatal error: Call to a member function format() on null in /in/sT2Ns on line 22
Process exited with code 255.
Output for 5.5.24 - 5.5.35
Fatal error: Call to a member function format() on a non-object in /in/sT2Ns on line 22
Process exited with code 255.

preferences:
184.69 ms | 401 KiB | 179 Q