3v4l.org

run code in 300+ PHP versions simultaneously
<?php error_reporting(E_ALL); ini_set('display_errors', true); class A { private $func = null; public function __construct($func) { $this->func = $func; } public function exec() { $this->func(); } } $a = new A(function() { echo 'works'; }); $a->exec();

preferences:
58.27 ms | 402 KiB | 5 Q