3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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 7.1.0
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.0.0 - 7.0.14
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 hhvm-3.10.0 - 3.13.2
bool(false) bool(true) 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.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.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.4.9
bool(false) bool(true) object(b)(0) { } object(a)(0) { }