3v4l.org

run code in 300+ PHP versions simultaneously
<?php private static function parseDateTime($value, string $format): \DateTimeImmutable { if ($value instanceof \DateTimeImmutable) { return $value; } if ($value instanceof \DateTime) { return \DateTimeImmutable::createFromMutable($value); } if (\is_numeric($value)) { return \DateTimeImmutable::createFromFormat('U.u', \sprintf('%.6F', $value)); } if (!\is_scalar($value)) { throw new InvalidFormatException("Cannot convert non-scalar value to date/time"); } if (!$result = \DateTimeImmutable::createFromFormat($format, $value)) { throw new InvalidFormatException("Cannot parse '{$value}' as a date/time using the format '{$format}'"); } return $result; }
Output for 7.1.0 - 7.1.16, 7.2.0 - 7.2.4
Parse error: syntax error, unexpected 'private' (T_PRIVATE), expecting end of file in /in/qGl71 on line 3
Process exited with code 255.

preferences:
181.27 ms | 1395 KiB | 29 Q