3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace Foo { class Bar { function baz() { return time(); } } } namespace { class Test { public static $now; function call() { $namespace = '\\Foo'; eval('namespace '.$namespace.' { function time() { return \\'.__CLASS__.'::$now ?: \time(); } }'); } } } $b = new Foo\Bar(); $t = new Test(); $t->call(); Test::$now = 'xxx'; $b->baz();
Output for 5.3.0 - 5.3.22, 5.4.0 - 5.4.12
Fatal error: No code may exist outside of namespace {} in /in/Nqq30 on line 26
Process exited with code 255.

preferences:
187.52 ms | 1399 KiB | 43 Q