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 = callWithArgs('str_replace', ['dolor', 'DOLOR', \T\ARGUMENT]); $string = 'Lorem ipsum dolor simet'; var_dump( $t($string) );
Output for 8.0.0 - 8.0.11
Fatal error: Uncaught Error: Undefined constant "T\ARGUMENT" in /in/mjOGD:17 Stack trace: #0 {main} thrown in /in/mjOGD on line 17
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.30, 7.4.0 - 7.4.24
Fatal error: Uncaught Error: Undefined constant 'T\ARGUMENT' in /in/mjOGD:17 Stack trace: #0 {main} thrown in /in/mjOGD on line 17
Process exited with code 255.
Output for 5.6.8 - 5.6.28
Fatal error: Undefined constant 'T\ARGUMENT' in /in/mjOGD on line 17
Process exited with code 255.
Output for 5.5.24 - 5.5.35
Parse error: syntax error, unexpected '.' in /in/mjOGD on line 13
Process exited with code 255.

preferences:
82.2 ms | 401 KiB | 98 Q