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.2
Parse error: syntax error, unexpected '$t' (T_VARIABLE), expecting ';' in /in/lMklZ on line 16
Process exited with code 255.
Output for 5.6.8 - 5.6.17
Parse error: syntax error, unexpected '$t' (T_VARIABLE) in /in/lMklZ on line 16
Process exited with code 255.
Output for 5.5.24 - 5.5.31
Parse error: syntax error, unexpected '.' in /in/lMklZ on line 13
Process exited with code 255.

preferences:
166.21 ms | 1395 KiB | 28 Q