3v4l.org

run code in 300+ PHP versions simultaneously
<?php $test = static function (string $expected, int $precision): void { $date = DateTimeImmutable::createFromFormat('U.u', $expected); echo 'Testing "', $date->format('Y-m-d H:i:s.u'), '" with given precision (', $precision, ')', PHP_EOL; ini_set('serialize_precision', $precision); $encoded = json_encode((float) $date->format('U.u')); var_dump($expected, $encoded, $expected === $encoded); if ($expected === $encoded) { echo PHP_EOL; return; } $adjustedPrecision = strlen($date->format('Uu')); echo 'Testing with adjusted precision (', $adjustedPrecision, ')', PHP_EOL; ini_set('serialize_precision', $adjustedPrecision); $encoded = json_encode((float) $date->format('U.u')); var_dump($expected, $encoded, $expected === $encoded); echo PHP_EOL; }; // $test('1487285080.123456', 8); // $test('1487285080.123456', 16); // $test('11487285080.123456', 16); // $test('112487285080.123456', -1); // $test('9999999999.999999', -1); $test('9999999999.999994', -1); $test('9999999999.999995', -1);
Output for git.master, git.master_jit
/bin/php-git-master: error while loading shared libraries: libonig.so.5: cannot open shared object file: No such file or directory
Process exited with code 127.
Output for rfc.property-hooks
Testing "2286-11-20 17:46:39.999994" with given precision (-1) string(17) "9999999999.999994" string(17) "9999999999.999994" bool(true) Testing "2286-11-20 17:46:39.999995" with given precision (-1) string(17) "9999999999.999995" string(17) "9999999999.999994" bool(false) Testing with adjusted precision (16) string(17) "9999999999.999995" string(17) "9999999999.999994" bool(false)

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
98.28 ms | 410 KiB | 5 Q