3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { static public function bar() { var_dump($this); } } try { $obj = new Foo; $obj->bar(); } catch (Throwable $e) { echo $e->getMessage() . "\n"; } try { call_user_func([new Foo, 'bar']); } catch (Throwable $e) { echo $e->getMessage() . "\n"; }
Output for 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Using $this when not in object context Using $this when not in object context
Output for 7.1.25 - 7.1.28, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33
Using $this when not in object context object(Foo)#3 (0) { }

preferences:
97.65 ms | 1408 KiB | 4 Q