3v4l.org

run code in 300+ PHP versions simultaneously
<<?php function validarData($date, $format = 'Y-m-d H:i:s') { $version = explode('.', phpversion()); if ((int) $version[0] >= 5 && (int) $version[1] >= 2 && (int) $version[2] > 17) { $d = DateTime::createFromFormat($format, $date); } else { $d = new DateTime(date($format, strtotime($date))); } return $d && $d->format($format) == $date; } var_dump(validarData('2014-02-31', 'Y-m-d'))
Output for 5.4.0 - 5.4.25
Parse error: syntax error, unexpected end of file in /in/1Hop4 on line 13
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected $end in /in/1Hop4 on line 13
Process exited with code 255.

preferences:
190.13 ms | 1395 KiB | 62 Q