3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace T ; define('ARGUMENT', uniqid()); function callWithArgs(callable $callback, array $args = []) { return function($param) use($callback, $args) { array_walk($args, function(&$arg) use($param) { $arg === \T\ARGUMENT and $arg = $param; }); return $callback(...$args); }; } $t = T\callWithArgs('str_replace', ['dolor', 'DOLOR', T\ARGUMENT]); $string = 'Lorem ipsum dolor simet'; var_dump( $t($string) );
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.30, 7.4.0 - 7.4.24, 8.0.0 - 8.0.11
Fatal error: Uncaught Error: Call to undefined function T\T\callWithArgs() in /in/MOhdm:17 Stack trace: #0 {main} thrown in /in/MOhdm on line 17
Process exited with code 255.
Output for 5.6.0 - 5.6.38
Fatal error: Call to undefined function T\T\callWithArgs() in /in/MOhdm on line 17
Process exited with code 255.
Output for 5.5.0 - 5.5.38
Parse error: syntax error, unexpected '.' in /in/MOhdm on line 13
Process exited with code 255.

preferences:
154.17 ms | 401 KiB | 209 Q