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 === ARGUMENT and $arg = $param; }); return $callback(...$args); }; } $t = callWithArgs('str_replace', ['dolor', 'DOLOR', ARGUMENT]); $string = 'Lorem ipsum dolor simet'; var_dump( $t($string) );
Output for 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.30, 7.4.0 - 7.4.24, 8.0.0 - 8.0.11
string(23) "Lorem ipsum DOLOR simet"
Output for 5.5.0 - 5.5.38
Parse error: syntax error, unexpected '.' in /in/RLNQc on line 13
Process exited with code 255.

preferences:
157.62 ms | 401 KiB | 245 Q