3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { static public function foo() { return $this instanceof Foo; } } class Bar { public function bar() { return Foo::foo(); } } $bar = new Bar; var_dump($bar->bar());
Output for 8.1.23 - 8.1.28, 8.2.10 - 8.2.18, 8.3.0 - 8.3.7
Fatal error: Uncaught Error: Using $this when not in object context in /in/KYOXt:6 Stack trace: #0 /in/KYOXt(14): Foo::foo() #1 /in/KYOXt(19): Bar->bar() #2 {main} thrown in /in/KYOXt on line 6
Process exited with code 255.
Output for 5.3.26, 5.4.16
Fatal error: Constructor Foo::foo() cannot be static in /in/2imLQ on line 8
Process exited with code 255.
Output for 5.3.0 - 5.3.24, 5.4.0 - 5.4.15
Fatal error: Constructor Foo::foo() cannot be static in KYOXt on line 8
Process exited with code 255.
Output for 5.3.25
Fatal error: Constructor Foo::foo() cannot be static in /in/KYOXt on line 8
Process exited with code 255.

preferences:
82.95 ms | 401 KiB | 72 Q