3v4l.org

run code in 300+ PHP versions simultaneously
<?php spl_autoload_register(function($className) { $internName = '___intern___' . str_replace(' ', '_', $className); eval('class ' . $internName . ' { static function foo() { echo "Bar"; } }'); class_alias($internName, $className); }); function with($className) { $className = $className . ' with ' . implode(', ', array_slice(func_get_args(), 1)); return new $className; } var_dump(with('Foo', 'Bar')); var_dump(call_user_func(['Foo with Bar', 'foo']));

preferences:
34.55 ms | 402 KiB | 5 Q