3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class A { function foo() { if (isset($this)) { echo '$this is defined ('; echo get_class($this); echo ") "; } else { echo "$this is not defined. "; } } } class B { function bar() { A::foo(); } } $a = new A(); $a->foo(); A::foo(); $b = new B(); $b->bar(); B::bar(); ?>
Output for 7.1.0
$this is defined (A) Deprecated: Non-static method A::foo() should not be called statically in /in/5gOhv on line 26 Fatal error: Uncaught Error: Using $this when not in object context in /in/5gOhv:11 Stack trace: #0 /in/5gOhv(26): A::foo() #1 {main} thrown in /in/5gOhv on line 11
Process exited with code 255.
Output for 7.0.0 - 7.0.14
$this is defined (A) Deprecated: Non-static method A::foo() should not be called statically in /in/5gOhv on line 26 Notice: Undefined variable: this in /in/5gOhv on line 11 is not defined. Deprecated: Non-static method A::foo() should not be called statically in /in/5gOhv on line 20 Notice: Undefined variable: this in /in/5gOhv on line 11 is not defined. Deprecated: Non-static method B::bar() should not be called statically in /in/5gOhv on line 29 Deprecated: Non-static method A::foo() should not be called statically in /in/5gOhv on line 20 Notice: Undefined variable: this in /in/5gOhv on line 11 is not defined.
Output for 5.6.7 - 5.6.28
$this is defined (A) Strict Standards: Non-static method A::foo() should not be called statically in /in/5gOhv on line 26 Notice: Undefined variable: this in /in/5gOhv on line 11 is not defined. Deprecated: Non-static method A::foo() should not be called statically, assuming $this from incompatible context in /in/5gOhv on line 20 $this is defined (B) Strict Standards: Non-static method B::bar() should not be called statically in /in/5gOhv on line 29 Strict Standards: Non-static method A::foo() should not be called statically in /in/5gOhv on line 20 Notice: Undefined variable: this in /in/5gOhv on line 11 is not defined.
Output for 5.1.3 - 5.5.35
$this is defined (A) Strict Standards: Non-static method A::foo() should not be called statically in /in/5gOhv on line 26 Notice: Undefined variable: this in /in/5gOhv on line 11 is not defined. Strict Standards: Non-static method A::foo() should not be called statically, assuming $this from incompatible context in /in/5gOhv on line 20 $this is defined (B) Strict Standards: Non-static method B::bar() should not be called statically in /in/5gOhv on line 29 Strict Standards: Non-static method A::foo() should not be called statically in /in/5gOhv on line 20 Notice: Undefined variable: this in /in/5gOhv on line 11 is not defined.
Output for 5.0.4 - 5.1.2
$this is defined (A) Strict Standards: Non-static method A::foo() should not be called statically in /in/5gOhv on line 26 Notice: Undefined variable: this in /in/5gOhv on line 11 is not defined. $this is defined (B) Strict Standards: Non-static method B::bar() should not be called statically in /in/5gOhv on line 29 Strict Standards: Non-static method A::foo() should not be called statically in /in/5gOhv on line 20 Notice: Undefined variable: this in /in/5gOhv on line 11 is not defined.
Output for 5.0.0 - 5.0.3
$this is defined (A) Strict Standards: Non-static method A::foo() should not be called statically in /in/5gOhv on line 26 Notice: Undefined variable: this in /in/5gOhv on line 11 is not defined. $this is defined (B) Strict Standards: Non-static method B::bar() should not be called statically in /in/5gOhv on line 29 Strict Standards: Non-static method A::foo() should not be called statically in /in/5gOhv on line 20 Notice: Undefined variable: this in /in/5gOhv on line 11 is not defined.
Output for 4.3.0 - 4.4.9
$this is defined (a) Notice: Undefined variable: this in /in/5gOhv on line 11 is not defined. $this is defined (b) Notice: Undefined variable: this in /in/5gOhv on line 11 is not defined.