3v4l.org

run code in 300+ PHP versions simultaneously
<?php class C { public function a() { echo __METHOD__ . "\n"; } public static function b() { var_dump($this); echo __METHOD__ . "\n"; } } $a = new C(); $a::b();
Output for 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught Error: Using $this when not in object context in /in/r5KeI:12 Stack trace: #0 /in/r5KeI(18): C::b() #1 {main} thrown in /in/r5KeI on line 12
Process exited with code 255.
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.38, 7.0.0 - 7.0.33
Notice: Undefined variable: this in /in/r5KeI on line 12 NULL C::b

preferences:
241.85 ms | 402 KiB | 293 Q