3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A{ function foo() { if(isset($this)) { return true; } return false; } function bar() { return $this; } } class B{ function bb() { $a = new A(); var_dump(A::bar()); var_dump($a->bar()); } } $a = new A; var_dump(A::foo()); var_dump($a->foo()); $b = new B(); $b->bb();
Output for 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: Non-static method A::foo() cannot be called statically in /in/1ishL:27 Stack trace: #0 {main} thrown in /in/1ishL on line 27
Process exited with code 255.
Output for 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.12 - 7.3.31, 7.4.0 - 7.4.33
Deprecated: Non-static method A::foo() should not be called statically in /in/1ishL on line 27 bool(false) bool(true) Deprecated: Non-static method A::bar() should not be called statically in /in/1ishL on line 21 Fatal error: Uncaught Error: Using $this when not in object context in /in/1ishL:14 Stack trace: #0 /in/1ishL(21): A::bar() #1 /in/1ishL(31): B->bb() #2 {main} thrown in /in/1ishL on line 14
Process exited with code 255.
Output for 7.3.32 - 7.3.33
bool(false) bool(true) Fatal error: Uncaught Error: Using $this when not in object context in /in/1ishL:14 Stack trace: #0 /in/1ishL(21): A::bar() #1 /in/1ishL(31): B->bb() #2 {main} thrown in /in/1ishL on line 14
Process exited with code 255.
Output for 7.0.0 - 7.0.20
Deprecated: Non-static method A::foo() should not be called statically in /in/1ishL on line 27 bool(false) bool(true) Deprecated: Non-static method A::bar() should not be called statically in /in/1ishL on line 21 Notice: Undefined variable: this in /in/1ishL on line 14 NULL object(A)#3 (0) { }
Output for 5.6.0 - 5.6.28
Strict Standards: Non-static method A::foo() should not be called statically in /in/1ishL on line 27 bool(false) bool(true) Deprecated: Non-static method A::bar() should not be called statically, assuming $this from incompatible context in /in/1ishL on line 21 object(B)#2 (0) { } object(A)#3 (0) { }
Output for 5.1.3 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38
Strict Standards: Non-static method A::foo() should not be called statically in /in/1ishL on line 27 bool(false) bool(true) Strict Standards: Non-static method A::bar() should not be called statically, assuming $this from incompatible context in /in/1ishL on line 21 object(B)#2 (0) { } object(A)#3 (0) { }
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.2
Strict Standards: Non-static method A::foo() should not be called statically in /in/1ishL on line 27 bool(false) bool(true) object(B)#2 (0) { } object(A)#3 (0) { }
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9
bool(false) bool(true) object(b)(0) { } object(a)(0) { }

preferences:
272.56 ms | 402 KiB | 359 Q