3v4l.org

run code in 300+ PHP versions simultaneously
<?php function convertToTimestamp($dateStr) { $dateStr = trim($dateStr); echo function_exists("date_create") if (!function_exists('date_create')) { return strtotime($dateStr); } $oDate = date_create($dateStr); if ($oDate instanceof DateTime) { #$curErrors = $oDate->getLastErrors(); #print_r($curErrors); #$curErrors = array_filter($curErrors, 'is_numeric'); #$curErrors = (bool)array_sum($curErrors); #if (!$curErrors) { return (int)$oDate->format('U'); #} } return false; } echo convertToTimestamp("2012-01-01"); // 1325376000 echo "<br>"; var_dump( convertToTimestamp("foo") ); // sollte false
Output for 5.4.0 - 5.4.6
Parse error: syntax error, unexpected 'if' (T_IF), expecting ',' or ';' in gHC7N on line 8
Process exited with code 255.
Output for 5.3.0 - 5.3.16
Parse error: syntax error, unexpected T_IF, expecting ',' or ';' in gHC7N on line 8
Process exited with code 255.

preferences:
163.28 ms | 1395 KiB | 31 Q