3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Example { public function test ($param) { $closure = function ($whatever) { return $this; }; return $closure($param); } public function test2 ($param) { $closure = function($this) { return $this; }; return $closure($param); } } $ex = new Example; $not_masked = $ex->test('foo'); $masked = $ex->test2('foo'); var_dump($not_masked, $masked);
Output for 7.0.7 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.29, 8.2.0 - 8.2.20, 8.3.0 - 8.3.8
Fatal error: Cannot use $this as parameter in /in/uguCc on line 12
Process exited with code 255.
Output for 7.0.0 - 7.0.6
object(Example)#1 (0) { } object(Example)#1 (0) { }
Output for 5.6.0 - 5.6.40
object(Example)#1 (0) { } string(3) "foo"

preferences:
187.37 ms | 1459 KiB | 7 Q