3v4l.org

run code in 300+ PHP versions simultaneously
<?php date_default_timezone_set('America/New_York'); class Block { private $start; private $end; private $callback; public function __construct($start, $end, callable $callback) { $this->start = $start; $this->end = $end; $this->callback = $callback; } public function check($time) { return $time > strtotime($this->start) && $time > strtotime($this->end); } public function invoke() { call_user_func($this->callback); } } $blocks = [ new Block('16:00:00', '18:00:00', function () { echo 'Foo!'; }), new Block('18:00:00', '20:00:00', function () { echo 'Bar!'; }), new Block('20:00:00', '22:00:00', function () { echo 'Qux!'; }), ]; while (true) { foreach ($blocks as $block) { if ($block->check()) { $block->invoke(); } } sleep(1); }
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught ArgumentCountError: Too few arguments to function Block::check(), 0 passed in /in/NYITM on line 37 and exactly 1 expected in /in/NYITM:14 Stack trace: #0 /in/NYITM(37): Block->check() #1 {main} thrown in /in/NYITM on line 14
Process exited with code 255.

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:
41.98 ms | 401 KiB | 8 Q