3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { private $count = 0; public function bar() { if (false) { return; } $this->count++; var_dump($this->count); } } class Bar { public function doSomething() { Foo::bar(); } } (new Bar)->doSomething();
based on PLTF1
Output for 7.0.0 - 7.3.0rc3
Deprecated: Non-static method Foo::bar() should not be called statically in /in/VC0GP on line 20 Fatal error: Uncaught Error: Using $this when not in object context in /in/VC0GP:11 Stack trace: #0 /in/VC0GP(20): Foo::bar() #1 /in/VC0GP(24): Bar->doSomething() #2 {main} thrown in /in/VC0GP on line 11
Process exited with code 255.
Output for hhvm-3.22.0
Fatal error: Uncaught Error: $this is null in /in/VC0GP:-1 Stack trace: #0 /in/VC0GP(-1): Foo::bar() #1 /in/VC0GP(-1): Bar->doSomething() #2 {main}
Process exited with code 255.
Output for hhvm-3.11.1 - 3.21.3
Fatal error: Uncaught Error: $this is null in /in/VC0GP:11 Stack trace: #0 /in/VC0GP(20): Foo::bar() #1 /in/VC0GP(24): Bar->doSomething() #2 {main}
Process exited with code 255.
Output for hhvm-3.10.1
Fatal error: $this is null in /in/VC0GP on line 11
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Deprecated: Non-static method Foo::bar() should not be called statically, assuming $this from incompatible context in /in/VC0GP on line 20 Notice: Undefined property: Bar::$count in /in/VC0GP on line 11 int(1)
Output for 5.5.0 - 5.5.38
Strict Standards: Non-static method Foo::bar() should not be called statically, assuming $this from incompatible context in /in/VC0GP on line 20 Notice: Undefined property: Bar::$count in /in/VC0GP on line 11 int(1)
Output for 5.4.0 - 5.4.45
Strict Standards: Non-static method Foo::bar() should not be called statically, assuming $this from incompatible context in /in/VC0GP on line 20 int(1)
Output for 5.1.0 - 5.3.29
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in /in/VC0GP on line 24
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_OBJECT_OPERATOR in /in/VC0GP on line 24
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/VC0GP on line 5
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/VC0GP on line 5
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/VC0GP on line 5
Process exited with code 255.