3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class Sleep { public static function for(Time $duration): void { usleep($duration->microseconds); } } readonly final class Time { public function __construct(public int $microseconds) { } public function add(self $time): self { return self::microseconds($this->microseconds + $time->microseconds); } public static function microseconds(int $duration): self { return new self($duration); } public static function milliseconds(int $duration): self { return new self($duration * 1000); } } function check(bool $a) { $sleep = Time::milliseconds(100); if ($a) { $sleep->add(Time::milliseconds(200)); } Sleep::for($sleep); echo 'CHECK:' . (new DateTime())->format(DateTimeInterface::ATOM); echo PHP_EOL; } echo 'OUTER_TIME: ' . (new DateTime())->format(DateTimeInterface::ATOM); echo PHP_EOL; check(false); echo 'OUTER_TIME: ' . (new DateTime())->format(DateTimeInterface::ATOM); echo PHP_EOL; check(true); echo 'OUTER_TIME: ' . (new DateTime())->format(DateTimeInterface::ATOM); echo PHP_EOL; // expected output: //OUTER_TIME: 2023-12-12T20:26:28+01:00 //Sleeping for 100 μseconds //CHECK:2023-12-12T20:26:28+01:00 // //OUTER_TIME: 2023-12-12T20:26:28+01:00 //Sleeping for 200 μseconds //CHECK:2023-12-12T20:26:28+01:00 // //OUTER_TIME: 2023-12-12T20:26:28+01:00
Output for git.master_jit, git.master
OUTER_TIME: 2023-12-12T20:41:07+01:00 CHECK:2023-12-12T20:41:07+01:00 OUTER_TIME: 2023-12-12T20:41:07+01:00 CHECK:2023-12-12T20:41:07+01:00 OUTER_TIME: 2023-12-12T20:41:07+01:00

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:
25.89 ms | 405 KiB | 5 Q