3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { public function isFoo() { var_dump($this); return $this instanceof Foo; } } class Bar { public function doSomething() { return Foo::isFoo(); } } $b = new Bar; var_dump($b->doSomething()); // bool(false)
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Fatal error: Uncaught Error: Non-static method Foo::isFoo() cannot be called statically in /in/hZfEG:12 Stack trace: #0 /in/hZfEG(16): Bar->doSomething() #1 {main} thrown in /in/hZfEG on line 12
Process exited with code 255.
Output for 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
Deprecated: Non-static method Foo::isFoo() should not be called statically in /in/hZfEG on line 12 Fatal error: Uncaught Error: Using $this when not in object context in /in/hZfEG:5 Stack trace: #0 /in/hZfEG(12): Foo::isFoo() #1 /in/hZfEG(16): Bar->doSomething() #2 {main} thrown in /in/hZfEG on line 5
Process exited with code 255.
Output for 7.3.32 - 7.3.33
Fatal error: Uncaught Error: Using $this when not in object context in /in/hZfEG:5 Stack trace: #0 /in/hZfEG(12): Foo::isFoo() #1 /in/hZfEG(16): Bar->doSomething() #2 {main} thrown in /in/hZfEG on line 5
Process exited with code 255.
Output for 7.0.0 - 7.0.20
Deprecated: Non-static method Foo::isFoo() should not be called statically in /in/hZfEG on line 12 Notice: Undefined variable: this in /in/hZfEG on line 5 NULL Notice: Undefined variable: this in /in/hZfEG on line 6 bool(false)
Output for 5.6.0 - 5.6.28
Deprecated: Non-static method Foo::isFoo() should not be called statically, assuming $this from incompatible context in /in/hZfEG on line 12 object(Bar)#1 (0) { } bool(false)
Output for 5.5.0 - 5.5.35
Strict Standards: Non-static method Foo::isFoo() should not be called statically, assuming $this from incompatible context in /in/hZfEG on line 12 object(Bar)#1 (0) { } bool(false)

preferences:
174.64 ms | 402 KiB | 231 Q