3v4l.org

run code in 300+ PHP versions simultaneously
<?php $dt1 = new \DateTimeImmutable('2017-01-01T00:00:00.000000Z'); $dt2 = new \DateTimeImmutable('2017-01-01T00:00:00.123456Z'); $diff = $dt1->diff($dt2); //var_dump($diff); var_dump($diff->f); var_dump(get_object_vars($diff)['f']); var_dump($diff->f === get_object_vars($diff)['f']);
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
float(0.123456) float(0.123456) bool(true)
Output for 5.5.8 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33
Notice: Undefined property: DateInterval::$f in /in/sM32U on line 7 NULL Notice: Undefined index: f in /in/sM32U on line 8 NULL Notice: Undefined property: DateInterval::$f in /in/sM32U on line 9 Notice: Undefined index: f in /in/sM32U on line 9 bool(true)
Output for 5.5.0 - 5.5.7
Fatal error: DateTime::diff() must be derived from DateTimeImmutable::diff in Unknown on line 0
Process exited with code 255.
Output for 5.4.0 - 5.4.45
Fatal error: Class 'DateTimeImmutable' not found in /in/sM32U on line 3
Process exited with code 255.
Output for 5.3.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/sM32U on line 8
Process exited with code 255.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/sM32U on line 3 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/sM32U on line 4 Parse error: syntax error, unexpected '[' in /in/sM32U on line 8
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1, 5.0.0 - 5.0.5
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/sM32U on line 3 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/sM32U on line 4 Parse error: parse error, unexpected '[' in /in/sM32U on line 8
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/sM32U on line 3 Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/sM32U on line 4 Parse error: parse error in /in/sM32U on line 8
Process exited with code 255.

preferences:
145.56 ms | 416 KiB | 5 Q